Xceed Workbooks for .NET v3.0 Documentation
Xceed.Workbooks.NET Assembly / Xceed.Workbooks.NET Namespace / Worksheet Class
Members Example


In This Topic
    Worksheet Class
    In This Topic
    Represents a single worksheet from a Workbook.
    Syntax
    'Declaration
     
    
    Public Class Worksheet 
       Inherits WorkbookElement
    'Usage
     
    
    Dim instance As Worksheet
    public class Worksheet : WorkbookElement 
    Example
    using( var doc = Workbook.Load( "test.xlsx") ) // Loads an existing Workbook named “test.xlsx”.
      {
        var worksheet = doc.Worksheets[ 1 ]; // Gets the second worksheet. 
        worksheet.Cells[ “A2” ].Value = 12; // Sets a value in “A2”.
        worksheet.Columns[ 1 ].Cells[ 0 ].Formula = “=SUM(A1:A2)”; // Sets a formula in “B1”.
        worksheet.Rows[ 3 ].Cells[ 3 ].Value = 40d; // Sets “D4” Value.
        worksheet.Name = “Years 2021”; // Sets a name for the Worksheet.
        worksheet.SheetView.ActiveCellAddress = “C2”; // Sets the cell with focus.
        worksheet.TabColor = Color.FromArgb( 0, 128, 0 ); // Sets the Tab color.
    
        worksheet.CalculateFormulas(); // Calculate the Value of “B1”, which contains a formula.
        doc.Save(); 
      }
    Inheritance Hierarchy

    System.Object
       Xceed.Workbooks.NET.WorkbookElement
          Xceed.Workbooks.NET.Worksheet

    Public Properties
     NameDescription
    Public PropertyGets the Worksheet's AnnotationCollection.  
    Public PropertyGets the Worksheet's CellCollection.  
    Public PropertyGets the Worksheet's ChartCollection.  
    Public PropertyGets the Worksheet's ColumnCollection.  
    Public PropertyGets the Worksheet's ConditionalFormattingCollection.  
    Public PropertyGets the DataValidations in the DataValidationCollection.  
    Public PropertyGets the Worksheet's HyperlinkCollection.  
    Public PropertyGets the current Worksheet's Id. A Workbook may contain more than one Worksheet. The first Id starts at 0.  
    Public PropertyGets if the Worksheet is currently protected. The default value is false.  
    Public PropertyGets the Worksheet's MergedCellCollection.  
    Public Property

    Gets or sets the Worksheet's name.

     
    Public PropertyGets the Worksheet's PageLayout.   
    Public PropertyGets the Worksheet's PictureCollection.  
    Public PropertyGets the WorksheetProtection as a read-only object.  
    Public PropertyGets the Worksheet's RowCollection.  
    Public PropertyGets the Worksheet's SheetView.  
    Public PropertyGets or sets the Color for the Worksheet's tab. The default value is null.  
    Public PropertyGets the Worksheet's TableCollection.  
    Public PropertyGets or sets the ThemeColor that the Worksheet will use on its tabs. The default value is null.  
    Public PropertyGets or sets how a Worksheet is displayed. The default setting is Visible.  
    Top
    Public Methods
     NameDescription
    Public MethodStarts the calculation process in all the Cells containing a formula and update their Value properties once the process is done.  
    Public MethodClears specific elements in the Worksheet.  
    Public MethodOverloaded. Deletes Columns at a specific index in the Worksheet.  
    Public MethodOverloaded. Deletes a CellRange and allows to specify in which direction the Cells located after the deleted range will be shifted.  
    Public MethodDeletes Rows at a specific index in the Worksheet.  
    Public Method

    Imports data of type Array, 2D-Array, ArrayList, ICollection, IDictionary, DataTable, DataView or CSV path/stream in a Worksheet.

     
    Public MethodOverloaded. Inserts new Columns at a specific index in the Worksheet.  
    Public MethodOverloaded. Inserts an empty CellRange and allows to specify in which direction the Cells located after the inserted range will be shifted.  
    Public MethodInserts new Rows at a specific index in the Worksheet.  
    Public Method

    Protects a Worksheet by enabling or disabling specific actions.

    This can be done with or without a password.

     
    Public MethodSearches into the content of the Worksheet and replaces all occurences of a specific value with a new value.  
    Public MethodSearches into the content of the Worksheet and replaces all instances of the SearchValues with their corresponding NewValues.  
    Public MethodUnprotects a Worksheet.  
    Top
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also