Thank you @timclaason,
yes, you're right with the stream reading, thats the problem of code re-using. Anyway I'm trying other XSSFWorkBook() with no luck, for example this with NPOI.OpenXml4Net.OPC.OPCPackage.
yes, you're right with the stream reading, thats the problem of code re-using. Anyway I'm trying other XSSFWorkBook() with no luck, for example this with NPOI.OpenXml4Net.OPC.OPCPackage.
try
{
HttpPostedFile postedFile = null;
string searchForFileName = Path.GetFileName(properties.BeforeUrl);
HttpFileCollection collection = _context.Request.Files;
NPOI.OpenXml4Net.OPC.OPCPackage xlsxPackage = null;
for (int i = 0; i < collection.Count; i++)
{
postedFile = collection[i];
if (searchForFileName.Equals(Path.GetFileName(postedFile.FileName), StringComparison.OrdinalIgnoreCase))
{
xlsxPackage = NPOI.OpenXml4Net.OPC.OPCPackage.Open(postedFile.InputStream);
}
}
return new XSSFWorkbook(xlsxPackage);
}
catch (Exception ex)
{
return null;
throw ex;
}
I will try with other different constructors, thanks.