This project has moved and is read-only. For the latest updates, please go here.

IE 8 error for streaming content

Jul 15, 2013 at 6:59 PM
The following code works in IE 9, All versions of Chrome, All Versions of Firefox.

However, IE 8 throws this error

__Unable to download EPExportExcel.aspx from localhost

Unable to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.__
The caught error is this:

{Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.}
  private void LoadExcel()
        {
            System.IO.FileInfo f = new System.IO.FileInfo(Server.MapPath("../Template.xlsx"));

         
            using (ExcelPackage pck = new ExcelPackage(f))
            {
                //Create a datasource
                DataTable tbl = ERSHelper.GetBTComparisonDataSource(_crit.FromDate, _crit.ThruDate, (int)_crit.NetworkType, (int)_crit.InboundProg);
                //create partial data with linq
                var query =
                            from o in tbl.AsEnumerable()
                            //where order.Field<bool>("OnlineOrderFlag") == true
                            select new
                            {
                                HLC = o.Field<string>("HLC"),
                                HLCName = o.Field<string>("HLCName"),
                                UniqueAcceptedIncidentCountHLC = o.Field<int>("UniqueAcceptedIncidentCountHLC"),
                                NotServicedIncidentCountHLC = o.Field<int>("NotServicedIncidentCountHLC"),
                                RefusedIncidentCountHLC = o.Field<int>("RefusedIncidentCountHLC"),
                                AcceptedRatioHLC = o.Field<decimal>("AcceptedRatioPctHLC"),
                                LoMilesHLC = o.Field<int>("LoMilesHLC"),
                                HiMilesHLC = o.Field<int>("HiMilesHLC"),
                                //DowntimeAllAllHLC = o.Field<decimal>("AcceptedRatioHLC"),
                                DowntimeLoAllHLC = o.Field<decimal>("DowntimeLoAllHLC"),
                                DowntimeHiAllHLC = o.Field<decimal>("DowntimeHiAllHLC"),
                                //DowntimeAllStdHLC = o.Field<decimal>("AcceptedRatioHLC"),
                                DowntimeLoStdHLC = o.Field<decimal>("DowntimeLoStdHLC"),
                                DowntimeHiStdHLC = o.Field<decimal>("DowntimeHiStdHLC"),
                                //DowntimeAllXOneHLC = o.Field<decimal>("AcceptedRatioHLC"),
                                DowntimeLoXOneHLC = o.Field<decimal>("DowntimeLoXOneHLC"),
                                DowntimeHiXOneHLC = o.Field<decimal>("DowntimeHiXOneHLC"),
                                AttemptRatioHLC = o.Field<decimal>("AttemptRatioHLC")
                            };
                // Create a table from the query.
                DataTable boundTable = ConvertToDataTable(query);
                //Create the worksheet
                ExcelWorksheet ws = pck.Workbook.Worksheets["Dashboard"];

                ws.Cells["A2"].Value = ERSHelper.BuildCriteriaTitle(_crit).Replace("<b>", "").Replace("</b>", "");
                ws.Cells["F6:F10000"].Style.Numberformat.Format = "#,##0.0";
                ws.Cells["I6:N10000"].Style.Numberformat.Format = "#,##0";
                ws.Cells["O6:O10000"].Style.Numberformat.Format = "#,##0.0";

                //Load the datatable into the sheet, starting from cell A6
                ws.Cells["A6"].LoadFromDataTable(boundTable, false);

                try
                {
                    //Write it back to the client
                    Response.Clear();
                    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                    Response.AddHeader("content-disposition", "attachment;  filename=BTComparison.xlsx");
                    Response.BinaryWrite(pck.GetAsByteArray());
                    Response.End();
                }
                catch (Exception ex)
                {
                    if (!(ex is System.Threading.ThreadAbortException))
                    {
                        //Other error handling code here
                    }
                }
            }
            



        }