Documents for Excel .NET Edition | GCDocuments
Features / Worksheet / Worksheet Views
In This Topic
    Worksheet Views
    In This Topic

    GcExcel offers customization of several display settings that are applied to a worksheet.

    In order to view a worksheet as per their own preferences, users can use the properties and methods of the IWorksheet interface, IPane interface and IWorksheetView interface.

    The following table describes some of the properties and methods that can be used to customize the view settings while working with worksheets.

    Property/Method Description
    IWorksheet.SplitPanes(int row, int column) This method can be used to lock the rows and columns in a worksheet in order to divide the worksheet into multiple areas that can be scrolled independently. Users need to provide the cell index as parameters in this method to specify the location where they want the split.
    IWorksheet.UnsplitPanes(int row, int column) This method can be used to unsplit the split panes. Using this method is similar to using IWorksheet.SplitPanes(0,0).

    IWorksheet.SplitRow

    IWorksheet.SplitColumn

    This method gets the split distances (row count and column count) from top (in case of row) or left (in case of column).
    IWorksheet.Panes A range object that represents the frozen or split panes of the worksheet.
    IWorksheet.ActivePane This property can be used to get the active pane in a worksheet.
    IPane.Activate() This method activates the current pane.
    IPane.Index This property can be used to get the index of the current pane in IWorksheet.Panes.

    IPane.ScrollColumn

    IPane.ScrollRow

    This property can be used to get or set the top left cell position of the current pane.
    IWorksheet.SheetView This property can be used to get the view of the worksheet.
    IWorksheetView.Zoom This property can be used to get and set a variant numeric value that represents the display size of the worksheet as a percentage where the 100 equals normal size, 200 equals double size, and so on.
    IWorksheetView.GridlineColor This property can be used to get and set the gridline color.
    IWorksheetView.ScrollColumn This property can be used to get and set the number of the leftmost column in the worksheet.
    IWorksheetView.ScrollRow This property can be used to get and set  the number of the row that appears at the top of the worksheet.
    IWorksheetView.DisplayRightToLeft This property can be used to get and set whether the specified worksheet is displayed from right to left instead of from left to right.
    IWorksheetView.DisplayFormulas This property can be used to get and set whether the worksheet displays formulas.
    IWorksheetView.DisplayGridlines This property can be used to get and set whether the gridlines are displayed.
    IWorksheetView.DisplayVerticalGridlines This property can be used to get and set whether the vertical gridlines are displayed.
    IWorksheetView.DisplayHorizontalGridlines This property can be used to get and set whether the horizontal gridlines are displayed.
    IWorksheetView.DisplayHeadings This property can be used to get and set whether the headers are displayed.
    IWorksheetView.DisplayOutline This property can be used to get and set whether the outline symbols are displayed.
    IWorksheetView.DisplayRuler This property can be used to get and set whether a ruler is displayed for the specified worksheet.
    IWorksheetView.DisplayWhitespace This property can be used to get and set whether the whitespace is displayed.
    IWorksheetView.DisplayZeros This property can be used to get and set whether the zero values are displayed.

    The following code snippet shows how to set custom view for a worksheet using different properties of the IWorksheet interface.

    C#
    Copy Code
    //Set worksheet view
    
    IWorkbook workbook = new Workbook();
    IWorksheet worksheet = workbook.Worksheets[0];
    var custom_view = worksheet.SheetView;
    custom_view.Zoom = 200;
    custom_view.GridlineColor = Color.Red;
    custom_view.ScrollColumn = 10;
    var scrollRow = custom_view.ScrollRow;
    
    

    The following code snippet shows how to use the SplitPanes() method to split the worksheet into panes.

    C#
    Copy Code
    //Split worksheet using SplitPanes() method
    
    Workbook workbook = new Workbook();
    IWorksheet worksheet = workbook.Worksheets[0];
    worksheet.SplitPanes(worksheet.Range["A5"].Row, worksheet.Range["A5"].Column);
    
    var splitRow = worksheet.SplitRow;
    var splitColumn = worksheet.SplitColumn;
    

    The following code snippet shows how to use the DisplayVerticalGridlines and DisplayHorizontalGridlines properties to display the vertical and horizontal gridlines of a worksheet. These gridlines are only visible while interacting with SpreadJS by doing JSON I/O and are not visible in Excel or PDF.

    C#
    Copy Code
    //create a new workbook
    var workbook = new Workbook();
    
    IWorksheet worksheet = workbook.Worksheets[0];
    
    worksheet.Range["A10"].Value = 10;
    
    //Set to not show horizontal gridlines
     worksheet.SheetView.DisplayHorizontalGridlines = false;
    
    //Set to show vertical gridlines
    worksheet.SheetView.DisplayVerticalGridlines = true;
    
    //Export workbook to json string and save to ssjson
    System.IO.File.WriteAllText("gridlines.ssjson", workbook.ToJson());

    Note: If the value of DisplayGridlines is set, DisplayVerticalGridlines and DisplayHorizontalGridlines are also set to the same value.