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

Commented Unassigned: Corrupted Excel files with NPOI - asp.net [12762]

$
0
0
Hi all, I need a small help with NPOI and asp.net.
I'm trying to create an excel file from a web application, written in asp.net (vb).
Everything is fine with excel 2003 xls format, while using the XSSF object model I get corrupted files.
Opening files in Excel I get the message that says file is corrupted, and can be restored (and actually Excel repairs it). The problem occurs even if I try to save stream into a file, rather than using memorystream.
Help is appreciated...
Here's the code, see attachment for error:

Dim wb As New XSSFWorkbook
Dim ws As new XSSFSheet
ws = wb.CreateSheet("Sheet1")
Dim r As XSSFRow
r = ws.CreateRow(0)
Dim c = r.CreateCell(0)
c.SetCellValue("Test")

Dim m As New IO.MemoryStream
m.Flush()
wb.Write(m)

Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
Response.AddHeader("content-disposition", "attachment;filename=test.xlsx")
Response.Clear()
Response.BinaryWrite(m.GetBuffer())

Response.End()
Comments: ** Comment from web user: chantszhim **

I got the same problem after migrating the site from Windows Server 2008 R2 to Windows Server 2012 R2.


Viewing all articles
Browse latest Browse all 1621

Trending Articles



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