0

i have exported excel file successfully but problem is that that exported excel file is not getting opened in android, whereas i have seen many applications that export files to excel and same files are getting opened on android, then why not my exported file?

//filled dt sucessfully
using (XLWorkbook wb = new XLWorkbook())
        {

            wb.Worksheets.Add(dt);


            Response.Buffer = true;

            using (MemoryStream MyMemoryStream = new MemoryStream())
            {

                wb.SaveAs(MyMemoryStream);

                //response starts

                Response.Cache.SetCacheability(HttpCacheability.Private);
                Response.CacheControl = "private";
                Response.Charset = System.Text.UTF8Encoding.UTF8.WebName;
                Response.ContentEncoding = System.Text.UTF8Encoding.UTF8;
                Response.AppendHeader("Content-Length", MyMemoryStream.Length.ToString());
                Response.AppendHeader("Pragma", "cache");
                Response.AppendHeader("Expires", "60");
                Response.AppendHeader("Content-Disposition",
                "attachment; " +
                "filename=\"Reports.xlsx\"; " +
                "size=" + MyMemoryStream.Length.ToString() + "; " +
                "creation-date=" + DateTime.Now.ToString() + "; " +
                "modification-date=" + DateTime.Now.ToString() + "; " +
                "read-date=" + DateTime.Now.ToString());
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                MyMemoryStream.WriteTo(Response.OutputStream);
                Response.Flush();
                Response.End();
            }
        }
  • Can you open the same file on windows / in ms office? Which app do you use on android to open the excel file? Do you get an error message? – Raidri Feb 12 '15 at 11:31
  • i can open file on windows. but when i try to open same file on android it says "this document can not be opened" using polaris office 5 – Abhijeet Bagul Feb 12 '15 at 11:52
  • any update on this. my issue is not resolved yet. still looking for option/resolution.. – Abhijeet Bagul Feb 19 '15 at 05:37

0 Answers0