Setting a sheet's page setup properties

In Excel OLE automation a sheet has a PageSetup property where I can set the LeftHeader, CenterHeader, RightHeader, LeftFooter, CenterFooter, RightFooter, PrintTitleRows, PrintTitleColumns. How can I do this in FlexCel?

The simplest way again is with APIMate. Just write the headers and footers you want in Excel, save the file and open it in APIMate and it will tell you how to change the properties you want.


Note that in Excel 2007 a new lot of options were added (like different headers and footers for odd and even pages), so there are 2 different sets of methods to set the page headers and footers:
1)A simple one by changing xls.PageHeader and xls.PageFooter
2) a more complex one with more options SetPageHeadersAndFooters. (APIMate will show SetPageHeadersAndFooters usage)

Everything is supported, even using images in headers or footers.
You can see a list of all the codes you can write inside the PageHeader or PageFooter string here:
http://www.tmssoftware.biz/flexcel/hlp/vcl/index.htm?FlexCel.Core.TExcelFile.PageHeader.htm

So for example, to write Hello at the left header and World at the right header you would do:
xls.PageHeader = "&LHello&RWorld"


Und PrintMargins (Top, Left, Right, Botton)?

Again, you can find out with APIMate. Just set some print margins in Excel, save the file and open it with APIMate. This is what I get:

 //Printer Settings

  //You can set the margins in 2 ways, the one commented here or the one below:
  //var PrintMargins: TXlsMargins;
  //  PrintMargins := xls.GetPrintMargins();
  //  PrintMargins.Left := 1;
  //  PrintMargins.Top := 1;
  //  PrintMargins.Right := 1;
  //  PrintMargins.Bottom := 1;
  //  PrintMargins.Header := 0.5;
  //  PrintMargins.Footer := 0.5;
  //  xls.SetPrintMargins(PrintMargins);
  xls.SetPrintMargins(TXlsMargins.Create(1, 1, 1, 1, 0.5, 0.5));

Und PrintTitleColumns?

PrintTitleColumns works by setting a named range (Print_Titles), as it is how it works internally in Excel. Again, APIMate is your friend:

  //Named Ranges
  RangeName := TXlsNamedRange.GetInternalName(TInternalNameRange.Print_Titles);
  Range := TXlsNamedRange.Create(RangeName, 1, 32, '=Sheet1!$A:$B,Sheet1!$1:$2');
  xls.SetNamedRange(Range);