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

New Post: EOF In Header exception when reading .xlsm

$
0
0
The context for my error is different than yours - I was not trying to open a file...I was creating one.

I can say that when I initialize a XSSFWorkbook (and get the underlying filestream), I don't use Stream.Read(). Why are you pushing the stream into a byte array when you already have the stream in the postedFile.InputStream?

In any event, this version of NPOI does seem a little temperamental...it seems like the interaction between XSSFWorkbook and the FileStream is a bit fragile...

I would try to initialize the XSSFWorkbook either by removing the lines of code where you initialize the byte array and read the stream into it...or, perhaps, consider returning the XSSFWorkbook using the PathAndFile constructor -- postedFile.FileName (or whatever attribute provides the entire path of the source file)...so, for instance, return new XSSFWorkbook(postedFile.FileName).

If you're having security issues or other technical issues directly opening postedFile.FileName, you could do a File.Copy(postedFile.FileName, TARGET_LOCATION)...then return new XSSFWorkbook(TARGET_LOCATION)


Good luck.

Viewing all articles
Browse latest Browse all 1621

Trending Articles



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