How to resolve the “File does not contain workbook stream” error?

8 Dec 20231 minute to read

XlsIO does not support files generated prior to 97-2003 version. Hence the exception “File does not contain workbook stream” occurs. This can be checked in prior with the below code snippet.

ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;

//To check whether the file is supported
FileStream stream = new FileStream("Sample.xls", FileMode.OpenOrCreate, FileAccess.ReadWrite);
var isSupported = application.IsSupported(stream);
excelEngine.Dispose();
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;

//To check whether the file is supported
var isSupported = application.IsSupported("Sample.xls");
excelEngine.Dispose();
Dim excelEngine As New ExcelEngine()
Dim application As IApplication = excelEngine.Excel

'To check whether the file is supported
Dim isSupported = application.IsSupported("Sample.xls")
excelEngine.Dispose()

NOTE

This method is available from 12.4 version onwards.

See Also