4

I'm getting this error trying to open some xls files using the Excel.ExcelReaderFactory (http://exceldatareader.codeplex.com/)

IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(stream);

excelReader.IsFirstRowAsColumnNames = false;
DataSet spreadsheetDocument = excelReader.AsDataSet();

Error: Neither stream 'Workbook' nor 'Book' was found in file

The error occures when you call CreateBinaryReader

Some files work 100%, but others give this exception. Does anyone have any ideas?

Similar question on their site (http://exceldatareader.codeplex.com/discussions/461766)

7
  • I did a compare between a file that works and a file that doesn't. The file that doesn't work has the following right at the bottom: Crystal Decisions Powered by Crystal Commented Oct 10, 2013 at 12:17
  • It would be wise to post your question in there discussion forum Commented Oct 10, 2013 at 12:18
  • Thanks - I'll do that as well Commented Oct 10, 2013 at 12:19
  • Do you have a file that causes the issue and a code sample? Commented Oct 11, 2013 at 2:50
  • I've added code - can this question be unheld? Commented Oct 11, 2013 at 12:47

1 Answer 1

2

This is from http://exceldatareader.codeplex.com/discussions/461766#post1113133 thought I'd post it here:

Same problem, same exception with crystal report xls file. This because 'Excel Data Reader' defines block strings as "Workbook" and "Book", instead Crystal Report as "WORKBOOK": you have to do a case insensitive comparison!

open "Excel\Core\BinaryFormat\XlsRootDirectory.cs" and replace line 75

if (e.EntryName == EntryName)

with

if (string.Equals(e.EntryName, EntryName, StringComparison.CurrentCultureIgnoreCase))

for me it solved.

have a nice day, marco

Sign up to request clarification or add additional context in comments.

3 Comments

Getting a new exception now: BIFF Stream error: Buffer size is less than entry length. on line 32 in XlsBiffRecord.cs
Added ReadOption.Loose to the CreateBinaryReader parameters _excelReader = ExcelReaderFactory.CreateBinaryReader(stream, ReadOption.Loose); and now it works 100%
one of my client try to upload excel and I found "BIFF Stream error: Buffer size is less than entry length" entry in my log DB, so I want to know when this error occurred ? (it's working fine for all other file).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.