This project has moved and is read-only. For the latest updates, please go here.

Page Layout and Scale To Width Rendering Issue

Sep 24, 2015 at 2:50 PM
Edited Sep 24, 2015 at 4:54 PM
I am currently attempting to generate an excel workbook where each sheets data has to fit to one page width and automatic height using the code below. The issue is that the sheets are not being rendered properly in excel.

printerSettings.FitToPage = true
printerSettings.FitToWidth = 1;
printerSettings.FitToHeight = 0;
printerSettings.Orientation = eOrientation.Landscape;

Solutions Tried:
  • Formatting the document programmatically before data is entered and manipulated
  • Formatting the document programmatically after data is entered and manipulated
  • Generating the document in normal view then switching it to page layout view programmatically
  • Generating the document in normal view then switching it to page layout in excel
The document is not being rendered properly when opened, see picture below
Image

If any settings are changed within excel that re-renders the document it is displayed correctly see image below.

Examples:
Going to print in the file menu shows the document rendered correctly and then the document is shown correctly
Changing the font size in a cell
Changing the font color in a cell
Checking the option to print or view gridlines/heading

Image

Any help on resolving the issue would be appreciated