ExcelWriter Xojo Plugin

ExcelWriterWorksheet.SetFooter Method

Sets footer text and header margin for the worksheet.

SetFooter(
   footer as String,
   footerMargin as Double)

Parameters

footer
The footer text and tags to set.
footerMargin
Margin in inches. If not wanting to change this value but only the text and formatting flags then pass down here ExcelWriterWorksheet.DEFAULT_FOOTER_MARGIN

Remarks

Excel headers and footers are generated from string with special formatting in them.

Formatting tags:
&L - Left Justification
&C - Center justification
&R - Right Justification
&P - Page number
&N - Total number of pages
&D - Date
&T - Time
&F - File name
&A - Worksheet name
&Z - Workbook path
&fontsize - Font size - where fontsize should be replaced by 2 digit font size
&"font,style" - Font name and style
&U - Single underline
&E - Double underline
&S - Strikethrough
&X - Superscript
&Y - Subscript


If no justification is specified in the formatting tags then text is by default centered.

Example text with flags

"&LSome test" - Will left align the text "Some test"

"&LSome&Cfooter&Rtest" - This will put "Some" to left, "footer" centered and "test" to right.

"&CPage &P of &N" -- this will center "Page 1 of 3"

"&C&\"Times New Roman,Regular\"Test" -- This will center "Test" using Times New Roman Regular


Dim f as FolderItem

f = GetSaveFolderItem("*.*","Headers and footers.xlsx")

if f <> nil then
    Dim writer as ExcelWriterWorkbook = ExcelWriterWorkbook.Create(f, ZStream.GetZipEngineHandle())
    Dim sheet as ExcelWriterWorksheet = writer.AddWorksheet()
   
    sheet.ColumnWidth(2) = 50
    sheet.CellText(2,2) = "When printed this document has headers and footers"
   
    sheet.SetHeader("&LEinhugur&C&F&RAuthor: Björn Eiríksson",ExcelWriterWorksheet.DEFAULT_HEADER_MARGIN)
    sheet.SetFooter("&CPage &P of &N",ExcelWriterWorksheet.DEFAULT_FOOTER_MARGIN)
   
    call writer.Close()
end if

See Also

ExcelWriterWorksheet Class