Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: "unreadable content" error when opening Excel file created via ClosedXML

$
0
0
SolanumVexus wrote:
I was getting a very similar error when downloading Excel files from an ASP.NET site.  Turns out I also needed the Content-Length header.  Here's a code snippet:   MemoryStream stream = export.ExportEx(types, ids); Response.Clear(); Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"; Response.AddHeader("content-disposition", "attachment;filename=\"AnalysisExport.xlsx\""); Response.AddHeader("Content-Length", stream.Length.ToString()); stream.WriteTo(Response.OutputStream); stream.Close();
Thank you SolanumVexus. You solved my problem with the Content-Length header.

Viewing all articles
Browse latest Browse all 1877

Trending Articles



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