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


In This Topic
    Workbook Class
    In This Topic
    Represents the root document containing the Worksheet(s).
    Syntax
    'Declaration
     
    
    Public Class Workbook 
    'Usage
     
    
    Dim instance As Workbook
    public class Workbook 
    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”.
        var stream = new MemoryStream();
        doc.SaveAs( stream); // Saves the result in a stream.
      }
    
        var stream = new MemoryStream();
        using( var doc = Workbook.Create( stream ) ) // Creates a workbook in a stream.
      {
        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”.
        doc.CalculateFormulas(); // Calculate the Value of “B1”, which contains a formula and for all other Worksheets containing cells with formulas.
        doc.Save(); // Saves the Workbook in the stream.
      }
    Inheritance Hierarchy

    System.Object
       Xceed.Workbooks.NET.Workbook

    Public Properties
     NameDescription
    Public PropertyGets if the Workbook is currently protected. The default value is false.  
    Public PropertyGets the name of the Workbook.  
    Public PropertyGets the WorkbookProtection as a read-only object.  
    Public PropertyGets the Workbook's Theme.  
    Public PropertyGets the list of all the WorkbookViews.  
    Public PropertyGets the collection of Worksheet that is part of this Workbook. A Workbook always have at least one Worksheet.  
    Top
    Public Methods
     NameDescription
    Public MethodStarts the calculation process for all the Cells containing a formula and update their Value properties once the process is done.  
    Public MethodClears specific elements in the Workbook.  
    Public Methodstatic (Shared in Visual Basic)Overloaded. Creates a new Workbook.  
    Public Method  
    Public Methodstatic (Shared in Visual Basic)Overloaded. Loads an existing Workbook.  
    Public Method

    Protects a Workbook by enabling or disabling specific actions. 

    This can be done with or without a password.

     
    Public MethodSearches into the content of the Workbook and replaces all occurences of a specific value with a new value.  
    Public MethodSearches into the content of the Workbook and replaces all instances of the SearchValues with their corresponding NewValues.  
    Public MethodSaves the Workbook.  
    Public MethodOverloaded. Saves the Workbook as a stream or as a new document.  
    Public MethodRemoves the protection that was added on the Workbook.  
    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