Follow us on X (Twitter)  Like us on Facebook  Connect with us on LinkedIn  Subscribe to our YouTube Channel  Subscribe to our WhatsApp Group

In last few articles we have discussed about NPOI libraries for .NET. There could be some cases, while reading Excel files, you may get an exception with 'The supplied spreadsheet seems to be Excel 5.0/7.0 (BIFF5) format. POI only supports BIFF8 format' as message.

 

In this quick tip, we are going to discuss about this issue, the way to handle it and the way to read the same Excel workbook content.

 

Solution for 'NPOI only supports BIFF8 format' exception (www.kunal-chowdhury.com)

 

This case may arise when you are trying to read an Excel document content using either of the 'XSSFExcelExtractor' for Excel 2007 format or 'ExcelExtractor' for Excel 97-2003 format. The root cause behind this would be an older Excel document that you are trying to read and the POI library does not support reading this file type. In such case, it will return the following exception message: 'The supplied spreadsheet seems to be Excel 5.0/7.0 (BIFF5) format. POI only supports BIFF8 format (from Excel versions 97/2000/XP/2003)'.

 

 

 

The stack trace for the above exception will look similar to the below snippet, with an exception object 'OldExcelFormatException':

 

NPOI.HSSF.OldExcelFormatException:
The supplied spreadsheet seems to be Excel 5.0/7.0 (BIFF5) format.
POI only supports BIFF8 format (from Excel versions 97/2000/XP/2003)
   at NPOI.HSSF.UserModel.HSSFWorkbook.GetWorkbookDirEntryName(DirectoryNode directory)
   at NPOI.HSSF.UserModel.HSSFWorkbook..ctor(DirectoryNode directory, Boolean preserveNodes)
   at NPOI.HSSF.UserModel.HSSFWorkbook..ctor(POIFSFileSystem fs)
   at NPOI.HSSF.Extractor.ExcelExtractor..ctor(POIFSFileSystem fs)

 

If you face this, you will have to handle this. If you are using NPOI library, it provides a different API class to read such older Excel documents (BIFF5 format). You will have to use the 'OldExcelExtractor' class, which is present in the 'NPOI.HSSF.Extractor' namespace. We have already discussed about it, in the last post, which you can read over here: How to read Excel 95 or older document (XLS) using NPOI libraries?. Point to note that, this will not able to read all the content from that Excel file due to technical limitation.

 

Do let me know, if you are facing any other difficulties. I would be happy to help you. Don't forget to share your views/comments on this.

 

 

Have a question? Or, a comment? Let's Discuss it below...

Thank you for visiting our website!

We value your engagement and would love to hear your thoughts. Don't forget to leave a comment below to share your feedback, opinions, or questions.

We believe in fostering an interactive and inclusive community, and your comments play a crucial role in creating that environment.