Back to Devexpress

Workbook.CreateNewDocument() Method

officefileapi-devexpress-dot-spreadsheet-dot-workbook.md

latest5.1 KB
Original Source

Workbook.CreateNewDocument() Method

Creates and loads a new empty workbook.

You need a license for the DevExpress Office File API Subscription or DevExpress Universal Subscription to use this property in production code.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Docs.v25.2.dll

NuGet Package : DevExpress.Document.Processor

Declaration

csharp
public bool CreateNewDocument()
vb
Public Function CreateNewDocument As Boolean

Returns

TypeDescription
Boolean

true , if the document is created successfully; otherwise, false.

|

Remarks

If the WorkbookEventOptions.RaiseOnModificationsViaAPI property is set to true and the document has unsaved changes (the Workbook.Modified property is true ), using the CreateNewDocument method will raise the Workbook.DocumentClosing event.

By handling the Workbook.DocumentClosing event, you can set e.Cancel to true to prevent a document from closing. In this case, the CreateNewDocument method will return false.

If the new document was created and successfully loaded, the CreateNewDocument method returns true.

The following code snippets (auto-collected from DevExpress Examples) contain references to the CreateNewDocument() 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.

spreadsheet-document-api-use-worksheet-data-bindings-to-process-data/CS/PerformanceCounterCorrelationExample/WorksheetProcessor.cs#L11

csharp
wb = new Workbook();
wb.CreateNewDocument();
Worksheet sheet = wb.Worksheets[0];

spreadsheet-document-api-chart-examples/CS/SpreadsheetDocServerChartAPISamples/Form1.cs#L441

csharp
{
    tempWorkbook.CreateNewDocument();
    tempWorkbook.Worksheets[0].CopyFrom(workbook.Worksheets.ActiveWorksheet);

spreadsheet-document-api-data-binding/CS/SpreadsheetApiDataBinding/Program.cs#L11

csharp
Workbook workbook = new Workbook();
workbook.CreateNewDocument();

spreadsheet-document-api-use-worksheet-data-bindings-to-process-data/VB/PerformanceCounterCorrelationExample/WorksheetProcessor.vb#L12

vb
wb = New Workbook()
wb.CreateNewDocument()
Dim sheet As Worksheet = wb.Worksheets(0)

spreadsheet-document-api-chart-examples/VB/SpreadsheetDocServerChartAPISamples/Form1.vb#L422

vb
Using tempWorkbook As New Workbook()
    tempWorkbook.CreateNewDocument()
    tempWorkbook.Worksheets(0).CopyFrom(workbook.Worksheets.ActiveWorksheet)

spreadsheet-document-api-data-binding/VB/SpreadsheetApiDataBinding/Program.vb#L10

vb
Dim workbook As New Workbook()
workbook.CreateNewDocument()

Implements

CreateNewDocument()

See Also

Workbook Class

Workbook Members

DevExpress.Spreadsheet Namespace