IXlDocument.CreateSheet() Method

Creates a new worksheet in the workbook and returns the IXlSheet object.

Namespace: DevExpress.Export.Xl

Assembly: DevExpress.Printing.v21.1.Core.dll

Declaration

IXlSheet CreateSheet()

Returns

Type Description
IXlSheet

An IXlSheet object that is the newly created worksheet.

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.

// 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";
    }
}
See Also