The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

IFormatDetectorService Interface

Allows detecting the format of a document contained in a stream.

Namespace: DevExpress.XtraSpreadsheet.Services

Assembly: DevExpress.Spreadsheet.v19.1.Core.dll

Declaration

public interface IFormatDetectorService
Public Interface IFormatDetectorService
public interface IFormatDetectorService
Public Interface IFormatDetectorService

Remarks

The built-in IFormatDetectorService service implementation detects the format of the document loaded from a stream using the SpreadsheetControl.DocumentSource property or one of the LoadDocument method overloads.

The table below lists all formats the service can detect and gives information about elements which are used to indicate the format.

Format Detected by
XLSX, XLSM, XLTX, XLTM Inner zip archive signature and the contents of the [Content_Types].xml file.
XLS, XLT (including Excel 97 - Excel 2003 (BIFF8) and 5.0/95(BIFF5) Binary file formats) Compound File Binary signature and the Workbook or Book stream availability in the CFB file.
CSV, TXT (only if loaded from a FileStream instance) Document file extension.
Important

The format of an encrypted XLSX/XLSM/XLTX/XLTM file cannot be detected (the DocumentFormat.Undefined value is returned).

If the IFormatDetectorService instance fails to detect the format, an InvalidFormatException exception is thrown.

You can implement your own format detector and register it as a service to use in your application.

Examples

using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("DXSpreadsheet.SampleDocument.xlsx"))
 {
    DocumentFormat format = spreadsheet.GetService<IFormatDetectorService>().DetectFormat(stream);
    spreadsheet.LoadDocument(stream, format);
 }
See Also