Document Solutions for Excel, .NET Edition | Document Solutions
Features / Worksheet / Customize Worksheets
In This Topic
    Customize Worksheets
    In This Topic

    DsExcel allows you to customize worksheets using the properties of IWorksheet Interface. You can perform useful operations like customizing gridlines to modify row and column headers, setting color for the tabs, or setting default height and width for rows and columns, and so much more.

    Customizing a worksheet to modify the default settings involves the following tasks:

    Configure display

    You can modify the display settings of your worksheet from left to right or right to left.

    Refer to the following example code to configure the display of your worksheet in DsExcel.

    C#
    Copy Code
    // Fetch the default WorkSheet
    IWorksheet worksheet = workbook.Worksheets[0];
    
    // Assign the values to the cells
    worksheet.Range["B1"].Value = "ABCD";
    worksheet.Range["B2"].Value = 3;
    worksheet.Range["C1"].Value = "Documents";
    worksheet.Range["C2"].Value = 4;
    worksheet.Range["D1"].Value = "Excel";
    worksheet.Range["D2"].Value = "ABCD";
    
    // Set the specified sheet to be displayed from left to right.
    worksheet.SheetView.DisplayRightToLeft = true;

    Set the tab color

    You can change the default tab color of your worksheet using the TabColor property of the IWorksheet interface.

    Refer to the following example code to set the tab color for your worksheet.

    C#
    Copy Code
    // Set the tab color of the specified sheet as green.
    worksheet.TabColor = Color.Green;

    Set visibility

    You can show or hide your worksheet using the Visible property of the IWorksheet interface.

    Refer to the following example code to set visibility of your worksheet.

    C#
    Copy Code
    // Adding new sheet and set the visibility of the sheet as Hidden.
    IWorksheet worksheet1 = workbook.Worksheets.Add();
    worksheet1.Visible = Visibility.Hidden;

    Set background image

    You can set a custom background image to your worksheet using the BackgroundPicture property of the IWorksheet interface. With this feature, users can insert any background image to the worksheet including their organization logo, custom watermark or a wallpaper of their choice without any hassles.

    Refer to the following example code in order to set the custom background image in your worksheet.

    C#
    Copy Code
    // Fetch default worksheet
    IWorksheet worksheet = workbook.Worksheets[0];
    
    // Set Background Image
    worksheet.BackgroundPicture = File.ReadAllBytes(@"Logo.png");

    Define standard width and height

    You can define the standard height and width of your worksheet using the StandardHeight and StandardWidth properties of the IWorksheet interface, respectively.

    Refer to the following example code to define the standard width and height as per your requirements.

    C#
    Copy Code
    // Setting the height and width of the wokrsheet
    worksheet.StandardHeight = 20;
    worksheet.StandardWidth = 40;
    See Also