Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does ClosedXML support setting a worksheet's zoom level?

I am using closedXML to generate an Excel file from C# and I am trying to see if there is anyway to set the zoom level of a worksheet. I can't find this in any of the documentation or from googling?

Does anybody know how to do this?

like image 243
leora Avatar asked Oct 18 '25 17:10

leora


2 Answers

It's now possible, starting with ClosedXML version 0.87.0, via the IXLSheetView.ZoomScale property.

using Excel = ClosedXML.Excel;

var wb = new Excel.XLWorkbook();
Excel.IXLWorksheet ws = wb.AddWorksheet("zoom");
Excel.IXLSheetView view = ws.SheetView;

/* Value can be set between 10 and 400 */
view.ZoomScale = 85;

You can check the IXLSheetView source code for more information.

like image 57
Métoule Avatar answered Oct 20 '25 07:10

Métoule


Update for version 0.87+: https://stackoverflow.com/a/52755386/2610249


No, ClosedXML does not support setting the zoom. The option that johny links to is only for scaling of the pages when printing.

There is a feature request on the ClosedXML page, but no answer from the developer.

like image 39
Raidri Avatar answered Oct 20 '25 07:10

Raidri