Back to Devexpress

IXlSheet Interface

corelibraries-devexpress-dot-export-dot-xl-d7fb9bb6.md

latest4.1 KB
Original Source

IXlSheet Interface

Represents a worksheet in a workbook.

Namespace : DevExpress.Export.Xl

Assembly : DevExpress.Printing.v25.2.Core.dll

NuGet Package : DevExpress.Printing.Core

Declaration

csharp
public interface IXlSheet :
    IDisposable
vb
Public Interface IXlSheet
    Inherits IDisposable

The following members return IXlSheet objects:

LibraryRelated API Members
Cross-Platform Class LibraryIXlDocument.CreateSheet()
BlazorGridExportCustomizeSheetEventArgs.Sheet
TreeListExportCustomizeSheetEventArgs.Sheet

Remarks

To create a new worksheet and add it to a workbook, call the IXlDocument.CreateSheet method. Use the IXlSheet object members to create worksheet columns and rows (IXlSheet.CreateColumn and IXlSheet.CreateRow), as well as objects of different types incorporated into the worksheet: hyperlinks (IXlSheet.Hyperlinks), pictures (IXlSheet.CreatePicture), etc.

For details on how to manage worksheets in a workbook, refer to the Worksheets section of examples.

Note

When you finish working with the IXlSheet object, call the Dispose method to release all the resources used by the object. Otherwise, generated content is not written to the output file. You can also modify the IXlSheet object within the using statement ( Using block in Visual Basic).

Example

The example below demonstrates how to add a worksheet to a workbook. To do this, use the IXlDocument.CreateSheet method.

To specify a worksheet name, use the IXlSheet.Name property. When naming a worksheet, take into account the constraints listed in the How to: Set a Worksheet Name document. If you do not specify a worksheet name, the default name “SheetN” is used, where N is a sequential number of a worksheet within a workbook.

Note

A complete sample project is available at https://github.com/DevExpress-Examples/excel-export-api-examples

csharp
// Create a new document.
using (IXlDocument document = exporter.CreateDocument(stream)) {

    // Specify the document culture.
    document.Options.Culture = CultureInfo.CurrentCulture;

    // Create a new worksheet under the specified name. 
    using (IXlSheet sheet = document.CreateSheet()) {
        sheet.Name = "Sales report";
    }
}
vb
' Create a new document.
Using document As IXlDocument = exporter.CreateDocument(stream)

    ' Specify the document culture.
    document.Options.Culture = CultureInfo.CurrentCulture

    ' Create a new worksheet under the specified name. 
    Using sheet As IXlSheet = document.CreateSheet()
        sheet.Name = "Sales report"
    End Using
End Using

See Also

IXlSheet Members

DevExpress.Export.Xl Namespace