Is there a way to preset the page margins Excel will use? I have looked for it, without success.
Yes, margins are fully supported. You can find them with APIMate.
I created a file in Excel, set some margins, and got this code:
//You can set the margins in 2 ways, the one commented here or the one below:
//var PrintMargins: TXlsMargins;
// PrintMargins := xls.GetPrintMargins();
// PrintMargins.Left := 0.905511811023622;
// PrintMargins.Top := 1.33858267716535;
// PrintMargins.Right := 0.905511811023622;
// PrintMargins.Bottom := 0.94488188976378;
// PrintMargins.Header := 0.511811023622047;
// PrintMargins.Footer := 0.511811023622047;
// xls.SetPrintMargins(PrintMargins);
xls.SetPrintMargins(TXlsMargins.Create(0.905511811023622, 1.33858267716535, 0.905511811023622, 0.94488188976378, 0.511811023622047, 0.511811023622047));
The units are all inches, as stated in the docs of TXlsMargins. I wish Excel used this same approach everywhere instead of the strange units it uses.
Thank you! I did find the first method after I posted, but I prefer the second. Still getting accustomed to the new records.
I fully agree about the issue of units. I need only support Excel 2007 and later, but have found that declaring the sheet to be Excel 2003 yields less distortion in scale of inserted images. Excel is a mess!