This project is read-only.

Sheet.FitToPage does not work with Excel 2007

May 7, 2012 at 8:38 AM

Hi all,

I am using the ISheet's FitToPage property along with the IPrintSetup's FitWidth and FitHeight properties and the IWorkbook's SetPrintArea as you can see below:

Sheet.PrintSetup.FitWidth = 1;
Sheet.PrintSetup.FitHeight = 0;
Sheet.FitToPage = true;
Workbook.SetPrintArea(0, 0, LastColumnIndex, 0, LastRowIndex);

The given settings are working as expected when I'm opening the created file using Excel 2003 but they're not working using Excel 2007.

When I open the .xls file in Excel 2007, the proper fields (Width, Height) are set to the correct values ("1" and "Automatic" accordingly), even the proper radio button is selected which tells not to use scaling, but in print preview there isn't what's desired.

If I re-select one of the values "1" or "Automatic" from the "Width" and "Height" comboboxes, the print layout appears as expected.

Can anyone help me on how to "tell" Excel 2007 to take into calculation the values of these fields, out of the box right after opening the file, without the need to change the settings manually?

Thanks in advance,