ExcelReaderFactory.CreateReader throwing exception for End of Central Directory mismatch when called with a MemoryStream
See original GitHub issueGiven the following:
private static void diffZipArchiveEntry(ZipArchiveEntry zipArchiveEntry1, ZipArchiveEntry zipArchiveEntry2)
{
using (var stream1 = zipArchiveEntry1.Open())
using (var stream2 = zipArchiveEntry2.Open())
using (var xlsxReader1 = ExcelReaderFactory.CreateReader(stream1))
using (var xlsxReader2 = ExcelReaderFactory.CreateReader(stream2))
{
// compare the two streams
}
}
A System.NotSupportedException
is thrown on the factory method. Just wanted to see if this intentional or not and whether I have to hit the disk and extract these .zip files before comparing the .xlsx inside them or whether it’s another issue entirely.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
Invalid Data Exception when using ExcelDataReader
End of Central Directory record could not be found. The Exception occurs from the second time I call the function. What Can Be...
Read more >WinZip error - central and local directory mismatch
A zip file is structured to have file headers preceding each file entry, followed at the end by a central directory. The central...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi,
ExcelDataReader requires a seekable stream as input, and after verifying with a little program, it appears
ZipArchiveEntry.Open()
does not return a seekable stream.To avoid the disk, there’s also an option to extract into a MemoryStream and pass that to the ExcelReaderFactory, if appropriate for your use case.
Rofl. Looks like I tried to load the same stream into a memory stream twice. Thanks for all your help!