I created an asp.net page that creates an Excel workbook. I set the orientation scaling property for page height and width for this book like this:
DocumentFormat.OpenXml.Spreadsheet.PageSetup pgOr = new DocumentFormat.OpenXml.Spreadsheet.PageSetup(); pgOr.Orientation = OrientationValues.Landscape; pgOr.FitToHeight = 3; pgOr.FitToWidth = 1; newWorksheetPart.Worksheet.AppendChild(pgOr);
However, when loading the Excel document and opening the PageSetup scaling, the value is set to 1 page wide and 3 pages high, which I want, but the "Fit to" switch is not selected, so it does not actually use these settings.
I realized that there is some property that I need to set to true. Like FitToPage or something that I donβt know which one. Somebody knows?
NOTE. Keep in mind that I'm using DocumentFormat.OpenXml and not Microsoft.Office.Interop.Excel.
source share