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

Feature request: Initial zoom of spreadsheet

Mar 16, 2011 at 8:04 PM

One nice-to-have feature of ClosedXML would be the ability to specify the initial zoom of a worksheet. I have an application that generates very large spreadsheets, and I would like to increase how much data appears when the sheet is opened without decreasing cell font size.

I suspect implementation would be trivial, as it requires only specifying a few of the following properties on the existing ClosedXML IXLSheetView interface:

  • zoomScale
  • zoomScaleNormal
  • zoomScalePageLayoutView
  • zoomScaleSheetLayoutView

All of the properties are integers in the range 10-400, and are documented at the bottom of the following MSDN page:

http://msdn.microsoft.com/en-us/library/documentformat.openxml.spreadsheet.sheetview.aspx

For me, zoomScale and zoomScaleNormal are the most useful, as they impact most of my end-user scenarios.

Thanks for the excellent project!

 

 

 

 

 

 

Nov 11, 2013 at 12:50 PM
This is a feature i would really like as well. Not sure how to raise up to get prioritized but hopefully this comment helps.
Apr 29, 2015 at 1:16 AM
I did implement it base on kbrimington suggetstion
__IXLSheetView.cs:__
/// <summary>
/// Window zoom magnification for current view representing percent values. Horizontal & Vertical scale together.
/// </summary>
/// <remarks>Representing percent values ranging from 10 to 400.</remarks>
Int32 ZoomScale { get; set; }
/// <summary>
/// Zoom magnification to use when in normal view. Horizontal & Vertical scale together
/// </summary>
/// <remarks>Representing percent values ranging from 10 to 400.</remarks>
Int32 ZoomScaleNormal { get; set; }
/// <summary>
/// Zoom magnification to use when in page layout view. Horizontal & Vertical scale together.
/// </summary>
/// <remarks>Representing percent values ranging from 10 to 400.</remarks>
Int32 ZoomScalePageLayoutView { get; set; }
/// <summary>
/// Zoom magnification to use when in page break preview. Horizontal & Vertical scale together.
/// </summary>
/// <remarks>Representing percent values ranging from 10 to 400.</remarks>
Int32 ZoomScaleSheetLayoutView { get; set; }


__XLSheetView.cs:__
private int _zoomScale { get; set; }
public int ZoomScale
{
    get { return _zoomScale; }
    set
    {
        _zoomScale = value;
        switch (View)
        {
            case XLSheetViewOptions.Normal:
                ZoomScaleNormal = value;
                break;
            case XLSheetViewOptions.PageBreakPreview:
                ZoomScalePageLayoutView = value;
                break;
            case XLSheetViewOptions.PageLayout:
                ZoomScaleSheetLayoutView = value;
                break;
        }
    }
}
public int ZoomScaleNormal { get; set; }
public int ZoomScalePageLayoutView { get; set; }
public int ZoomScaleSheetLayoutView { get; set; }

__XLWorkbook_Save.cs__
Function GenerateWorksheetPartContent
...
#region SheetViews
...
sheetView.ZoomScale = (UInt32)xlWorksheet.SheetView.ZoomScale;
sheetView.ZoomScaleNormal = (UInt32)xlWorksheet.SheetView.ZoomScaleNormal;
sheetView.ZoomScalePageLayoutView = (UInt32)xlWorksheet.SheetView.ZoomScalePageLayoutView;
sheetView.ZoomScaleSheetLayoutView = (UInt32)xlWorksheet.SheetView.ZoomScaleSheetLayoutView;
...
Apr 8, 2016 at 4:45 PM
I cannot see where this is implemented. The most current version I have is 0.76.0 from Dec 2014. This looks as if it was implemented after that date. Where/how do we get this?
Apr 9, 2016 at 5:49 PM
Sorry, I did not push my version because I did other changes for my specific needs which are not related to that.
You have everything you need in my last post to make the change yourself.
Jan 31 at 3:49 PM
Marked as answer by igitur on 5/5/2017 at 3:40 AM