Skip to main content

IXlExporter.CreateDocument(Stream) Method

Creates a new document and writes it to the specified stream.

Namespace: DevExpress.Export.Xl

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

NuGet Package: DevExpress.Printing.Core

Declaration

IXlDocument CreateDocument(
    Stream stream
)

Parameters

Name Type Description
stream Stream

The System.IO.Stream object to output the document to.

Returns

Type Description
IXlDocument

An IXlDocument object that is the newly created workbook.

Remarks

Note

When you finish working with the IXlDocument 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 IXlDocument object within the using statement (Using block in Visual Basic).

Example

The example below demonstrates how to create a new document and write it to the specified file stream using the IXlExporter.CreateDocument method.

// Create an exporter instance. 
IXlExporter exporter = XlExport.CreateExporter(XlDocumentFormat.Xlsx);
// Create the FileStream object with the specified file path. 
using (FileStream stream = new FileStream("Document.xlsx", FileMode.Create, FileAccess.ReadWrite))
{

    // Create a new document and write it to the specified stream. 
    using (IXlDocument document = exporter.CreateDocument(stream))
    {
        // Specify the document culture.
        document.Options.Culture = CultureInfo.CurrentCulture;
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the CreateDocument(Stream) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also