I am having an issue. I need to set the print settings on a generated excel doc to “Fit all columns on one page”
The process is… Client does report, exports to excel, downloads to desktop, may decide to print.
The only option I’ve found for this is in the excel print to pdf conversion, which is not helpful to me.
FitToPagesWide = 1 does not work either. It makes the text too small to read.
Hi Cliff,
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.AllColumnsInOnePagePerSheet = true;
SheetRender sheetRender = new SheetRender(workbook.Worksheets[0], options);
sheetRender.ToPrinter(“Printer Name”);
WorkbookRender workbookRender = new WorkbookRender(workbook, options);
workbookRender.ToPrinter(“Printer Name”);
My understanding of that code is that is for when someone presses a link on a webpage to print something. I don’t have that option. They need to download the excel file then be able to hit file > print and the print settings by default are set to fit all columns on one page.
Hi Cliff,
Workbook workbook = new Workbook(“book1.xlsx”);
foreach (Worksheet sheet in workbook.Worksheets)
{
sheet.PageSetup.FitToPagesWide = 1;
sheet.PageSetup.FitToPagesTall = 0;
}
workbook.Save(“output.xlsx”);
Please note, setting the worksheet to Fit All Columns On One Page should be used when there are not to many columns otherwise you may end up with very small printed text as you have narrated in your original post.