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

Commented Unassigned: NPOI Open Xlsx document modified on Apple system [13967]

$
0
0
Hi everyone,

i've a problem when i try to open a workbook with XSSFWorkbook method.
With a lot of xlsx file i've got no problem, but if we made some changes on a excel file with a Mac Pro and try to open it in my project i got this error stacktrace :

```
Wrong Local header signature: 0x4ACF92AD
ICSharpCode.SharpZipLib
```

```
à ICSharpCode.SharpZipLib.Zip.ZipInputStream.GetNextEntry()
à NPOI.OpenXml4Net.Util.ZipInputStreamZipEntrySource..ctor(ZipInputStream inp)
à NPOI.OpenXml4Net.OPC.ZipPackage..ctor(Stream filestream, PackageAccess access)
à NPOI.OpenXml4Net.OPC.OPCPackage.Open(Stream in1)
à NPOI.Util.PackageHelper.Open(Stream is1)
à NPOI.XSSF.UserModel.XSSFWorkbook..ctor(Stream is1)
```

You can found code i wrote below :

```
protected static IWorkbook GetWorkbook(FileInfo file)
{
IWorkbook workBook = null;

using (var stream = file.OpenRead())
{
stream.Position = 0; // <-------- rewind the stream
if (file.Name.ToUpper().EndsWith(".XLSX"))
workBook = new XSSFWorkbook(stream);
else if (file.Name.ToUpper().EndsWith(".XLS"))
workBook = new HSSFWorkbook(stream);
}

return workBook;
}
```

I think i've a problem when we save it on Appel and try to read it on Microsoft system.

How can i do to solve it and allow my project to open Excel file by any possible mean ?

Thanks a lot
Comments: ** Comment from web user: vigotSev **

For information we used "Numbers" software to modify it and convert it in xlsx file.

i think header signature generated doesn't use the same signature algorithm that we get on Microsoft Excel software.


Viewing all articles
Browse latest Browse all 1621

Trending Articles



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