Problem to response the xls File to the Client

Mar 19, 2014 at 10:49 PM
Hi there, my problem is the file is not writing to the client side nothing happening

my code is above:
            //Save the Excel spreadsheet to a MemoryStream and return it to the client
            using (var exportData = new MemoryStream())
                    string saveAsFileName = string.Format("ObrasNuevas-{0:d}.xls", DateTime.Now).Replace("/", "-");
                    Context.Response.ContentType = "application/";
                    Context.Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", saveAsFileName));
                catch (Exception ex)

my server is Windows 2003 , only work with chrome but with ie i cant get the xls file

I really Appreciate your comments.
Mar 25, 2014 at 6:39 PM
First off, I just wanted to point out that your issue is not with NPOI.

Next, looking at your code, I believe you may need to add the content size to the response header.

Try adding the following immediately after the addition of the Content-Disposition to the header:
Context.Response.AddHeader("Content-Length", exportData.Length.ToString());
If that doesn't solve your problem, try changing the Content-Type from application/ to application/octet-stream.

Marked as answer by tonyqus on 4/12/2014 at 1:58 PM
Mar 28, 2014 at 3:59 PM
Thanks for your time MindCore, I find that my problem is not with NPOI, my problem was an error in IE thant does not unsderstand the JSON i have to add a JSCRIPT File the implement the JSON the File "minjson2.js" that implemente the methods JSON.stringify(Objeto) and other that suppose are native in the navigator.

Sorry my english is not very well thanks for your time to advice.