officefileapi-devexpress-dot-xtraspreadsheet-dot-services-dot-iformatdetectorservice-dot-detectformat-x28-system-dot-io-dot-stream-x29.md
Determines the format of the document contained in a stream.
Namespace : DevExpress.XtraSpreadsheet.Services
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
DocumentFormat DetectFormat(
Stream stream
)
Function DetectFormat(
stream As Stream
) As DocumentFormat
| Name | Type | Description |
|---|---|---|
| stream | Stream |
A Stream object that is the stream containing the document.
|
| Type | Description |
|---|---|
| DocumentFormat |
A DocumentFormat enumeration value specifying the document format.
|
The target stream should meet the following requirements:
The following formats can be detected.
Important
The format of encrypted XLSX/XLSM/XLTX/XLTM file cannot be detected (the DetectFormat method returns DocumentFormat.Undefined).
If the DetectFormat method fails to detect the format, it returns DocumentFormat.Undefined.
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("DXSpreadsheet.SampleDocument.xlsx"))
{
DocumentFormat format = spreadsheet.GetService<IFormatDetectorService>().DetectFormat(stream);
spreadsheet.LoadDocument(stream, format);
}
Using stream As Stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("DXSpreadsheet.SampleDocument.xlsx")
Dim format As DocumentFormat = spreadsheet.GetService(Of IFormatDetectorService)().DetectFormat(stream)
spreadsheet.LoadDocument(stream, format)
End Using
See Also
IFormatDetectorService Interface