ASP.NET C# - iPhone Web Form - Export to Excel, then open in Mail App RRS feed

  • Question

  • In my ASP.NET Web Form project that has the following code behind the page to export a ReportViewer Local Report to an excel document:

    private void CreateDoc(string fileName, string fileType)
                // Variables
                Warning[] warnings;
                string[] streamIds;
                string mimeType = string.Empty;
                string encoding = string.Empty;
                string extension = string.Empty;
                byte[] bytes = rvEquipInven.LocalReport.Render(fileType, null, out mimeType, out encoding, out extension, out streamIds, out warnings);
                // Now that you have all the bytes representing the PDF report, buffer it and send it to the client.
                Response.Buffer = true;
                Response.ContentType = mimeType;
                Response.AddHeader("content-disposition", "attachment; filename=" + fileName + "." + extension);
                Response.BinaryWrite(bytes); // create the file
                Response.Flush(); // send it to the client to download

    The reason why I don't use the default export options already included with the ReportViewer Control is because they do not show up on the iPhone. The code above has been a universial and viable solution. However, I have one relatively annoying issue. When I run this code on an iPhone (or iPad), it exports it to an excel and automatically displays it with default viewer in safari. It has the "Open in..." option, however it does not display the default iOS Mail App. It does give me the option for the Outlook Mail App, but not everyone who uses this web app will use Outllook's app. A workaround would be to open it up in the "Numbers" app or "Excel" app and then email it from there, but this seems like a waste of time for what should be a simple fix.

    When I run this code on a PC or Android phone, it downloads first, but does not open it up for viewing, allowing for the option of sending it with the default Mail App (on the Android Phone). Therefore, is there a way to do this in iOS, force it to download only and not view? Or a way to "push" it into the defaul Mail App? I've read up on Malito Links, but the only way that can work is if I can copy the layout of the tabled report in the ReportViewer Control and then send it. Any ideas on that? Maybe another way to export it in excel format other than what I currently am using? Any ideas??


    • Moved by Caillen Monday, July 13, 2015 10:12 AM
    Monday, July 13, 2015 1:20 AM


  • Hi Gerneio,

    Please post in Web Forms forum here:


    More web developers there will give you help. Thanks for your understanding.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Just Karl Monday, July 13, 2015 3:26 PM
    • Marked as answer by Just Karl Friday, July 31, 2015 4:51 PM
    Monday, July 13, 2015 10:12 AM