Quantcast
Channel: NPOI
Viewing all articles
Browse latest Browse all 1621

New Post: Using NPOI.SS.UserModel to open both XLS and XLSX for reading

$
0
0

Using NPOI 2.0 Alpha

I am having an issue opening an Excel 2007 (xlsx) Workbook.  I receive the following error:

The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF)

The error is occurring on the following line (yes, VB.NET)

        Dim xlWBAs IWorkbook = DirectCast(WorkbookFactory.Create(New POIFSFileSystem(New FileStream(Me.solFilePath, FileMode.Open, FileAccess.Read))), XSSFWorkbook)

I know that NPOI is modeled after Apache POI, and I have used Apache POI's SS UserModel to read both xls and xlsx files in Java without having to change anything.  As you can see above, I tried to cast it to an XSSFWorkbook, but that didn't work either.  What am I doing wrong, or is the SS UserModel in NPOI not capable of reading both xls and xlsx?


Viewing all articles
Browse latest Browse all 1621

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>