DocumentFormat Struct
A document format.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v19.1.Core.dll
Declaration
Related API Members
The following members return DocumentFormat objects:
Library | Related API Members |
---|---|
WPF Controls | SpreadsheetDocumentSource.Format |
SpreadsheetImportOptions.FallbackFormat | |
SpreadsheetSaveOptions.CurrentFormat | |
SpreadsheetSaveOptions.DefaultFormat | |
Office File API | IFormatDetectorService.DetectFormat(Stream) |
SpreadsheetBeforeExportEventArgs.DocumentFormat | |
SpreadsheetBeforeImportEventArgs.DocumentFormat | |
WorkbookImportOptions.FallbackFormat | |
WorkbookSaveOptions.CurrentFormat | |
WorkbookSaveOptions.DefaultFormat | |
ASP.NET Core Controls | SpreadsheetDocumentInfo.DocumentFormat |
ASP.NET Web Forms Controls | SpreadsheetDocumentInfo.DocumentFormat |
Remarks
The DocumentFormat structure introduces fields to specify the file format with which a workbook can be saved or from which it can be loaded. Use the ISpreadsheetComponent.SaveDocument and ISpreadsheetComponent.LoadDocument methods to specify the document format.
The following example illustrates how to save a workbook in XLSX format.
Call the SpreadsheetControl.SaveDocument with the file path as a parameter to save a workbook to the file. Specify the file format as the second parameter of the method using the DocumentFormat
enumerator.
Note
Certain methods can throw unhandled exceptions if a problem occurs. Consider the situation when a document is being saved to a locked or read-only file. To prevent application failure, subscribe to the SpreadsheetControl.UnhandledException event and set the SpreadsheetUnhandledExceptionEventArgs.Handled property to true.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/winforms-spreadsheetcontrol-api-e4655
// Save the modified document to a file.
spreadsheetControl1.SaveDocument("Documents\\SavedDocument.xlsx", DocumentFormat.OpenXml);
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the DocumentFormat struct.
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.