TFlexCelPreviewer landscape?

Hi 
How can you rotate the page layout to landscape in the FlexcelPreviewer?

Using the custom Preview demo.

Thnaks

FlexCelPreviewer will use the orientation in the Excel file. This is because a single excel file can have some sheets in landscape and some in portrait, and when printing the previewer has to respect that.


So, in order to change the orientation, you need to change it in the Excel file itself (note that as said, every sheet might have a different orientation).
If working in Excel, just change it from the print settings. If you want to change it programatically, use something like:

To change a single sheet:
  xls.ActiveSheetByName := 'sheet1';
  xls.PrintLandscape := true;

To change all sheets:
 for i := 1 to xls.SheetCount do
begin
   xls.ActiveSheet := i;
   xls.PrintLandscape := true;
end;

After doing this, you need to refresh the previewer:
FlexCelPreviewer.InvalidatePreview;

Regards, 
   Adrian.

Thanks for the quick answer!


Can we also adjust the page margins in the FlexCelPreviewer?

Regards

Yes, same as landscape (and most print options, which can vary per sheet) you need to change the margins in the xls file. As always, the easiest way to know how to do it is to create a file in Excel, change the margins, and open the file in APIMate. This is what I get:


  //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));

Regards,
  Adrian.