Skip to main content
.NET Framework 4.5.2+

IFormatDetectorService Interface

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

Namespace: DevExpress.XtraSpreadsheet.Services

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


public interface IFormatDetectorService


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, XLSB, 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.


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.


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