Oracle -> Write excel file from PL/SQL -> Tutorial 6
 

Tutorials

For paper layout you can define things like margins and headers and footers. For this we have:

    TYPE t_rec_printSetup  IS RECORD(
         landscape          BOOLEAN
        ,headerLeft         VARCHAR2(500)
        ,headerCenter       VARCHAR2(500)
        ,headerRight        VARCHAR2(500)
        ,headerMargin       NUMBER
        ,footerLeft         VARCHAR2(500)
        ,footerCenter       VARCHAR2(500)
        ,footerRight        VARCHAR2(500)
        ,footerMargin       NUMBER
        ,pageMarginTop      NUMBER
        ,pageMarginBottom   NUMBER
        ,pageMarginLeft     NUMBER
        ,pageMarginRight    NUMBER
        ,printTitle         VARCHAR2(20)
        ,printArea          VARCHAR2(20)
        ,fitToPage          VARCHAR2(1)
        ,printGrid          BOOLEAN
        ,printRowColHeadings BOOLEAN
        ,printBlackAndWhite BOOLEAN
        ,printDraftQuality  BOOLEAN
        );
landscape
TRUE = landscape, FALSE or NULL = portrait.
headerLeft/Center/Right
Text for header (see below).
headerMargin
Distance of header from top
footerLeft/Center/Right
Text for footer (see below)
footerMargin
Distance of footer from bottom
pageMarginX
Page margin
printTitle
When you have headers in your sheet it can be useful to repeat them on every printed page, the same for descriptive columns. E.g. you want to repeat row 2-4 on every page, then you set printTitle = 'R2:R4', accordingly for columns 'C1:C2' or combined 'C1:C2,R2:R4'
printArea
Printing area, format 'R1C1:R33C13'
fitToPage
Scale output on one page: Columns (C), Rows (R), Worksheet (W)
printRowColHeadings
Print heading A,B,... and row numbers! FALSE = don't print, Default = TRUE
printBlackAndWhite
Print only black and white TRUE = no colour, Default = FALSE
printDraftQuality
Print lower quality TRUE = Draft quality, Default = FALSE

Margins are set in in cm. Within the file they are written as inch. So when you want to take measures from the source of an existing file then you have to multiply them by 2,54.

Header and footer

Header and footer are each divided into three parts - Left/Center/Right. Accordingly the text is aligned left, centered and right. To format the text there are defined variables and constants, other formattings are not supported at the moment. The length of the texts (including meta tags) is limited to about 800 characters.

Warning: this feature depends on the language settings of the OS. Currently only the German output works correctly.

c_mtPage
current page number
c_mtPageTotal
total pages
c_mtTime
current timestamp
c_mtDate
current date
c_mtPath
path to file location
c_mtName
file name
c_mtTab
name of the worksheet
c_mtFontSize8/10/12/14
font size
c_mtFontBold
font bold
c_mtFontItalic
font italic
c_mtFontBoldItalic
font bold and italic
c_mtFontStandard
font standard (not bold, not italic)

Examples

Display page x from y bottom right

footerRight := 'Page '||xml_spreadsheet.c_mtPage||
    '/'||xml_spreadsheet.c_mtPageTotal;

Title centered with bold and standard text, including line break

headerCenter := xml_spreadsheet.c_mtFontBold||'Bold text'||CHR(10)||
    xml_spreadsheet.c_mtFontStandard||'with standard second line';