Solution for NPOI only supports BIFF8 format exception

Solution for NPOI only supports BIFF8 format exception


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)'.

 

You may like to read:



 

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.

 

 



If you have come this far, it means that you liked what you are reading. Why not reach little more and connect with me directly on Twitter, Facebook, Google+ and LinkedIn. I would love to hear your thoughts and opinions on my articles directly. Also, don't forget to share your views and/or feedback in the comment section below.

0 comments

 
© 2008-2017 Kunal-Chowdhury.com - Microsoft Technology Blog for developers and consumers | Designed by Kunal Chowdhury
Back to top