嗨,我正在尝试将网格数据导出到 excel,但它在 IE8 中不起作用。我正在使用包含 2 个按钮“确定”和“关闭”的 Ajax 模态弹出对话框。点击确定,我想下载 excel 文件。它可以工作在 Mozilla 中很好,但在 IE 中它不起作用。我正在使用下面的代码。请建议我该怎么做?另外,当我首先打开文件时,它会在打开文件之前显示警告如何处理?
  Response.Clear();
    Response.Buffer = true;
    string filename = "Checkout";
     Response.Charset = "";
    Response.ContentType = "application/vnd.ms-excel";
    Response.AddHeader("content-disposition", "attachment; filename=" + filename + ".adt");
    Response.Write("<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">");
    Response.Write("<head>");
    Response.Write("<META http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
    Response.Write("<!--[if gte mso 9]><xml>");
    Response.Write("<x:ExcelWorkbook>");
    Response.Write("<x:ExcelWorksheets>");
    Response.Write("<x:ExcelWorksheet>");
    Response.Write("<x:Name>Sheet1</x:Name>");
    Response.Write("<x:WorksheetOptions>");
    Response.Write("<x:Print>");
    Response.Write("<x:ValidPrinterInfo/>");
    Response.Write("</x:Print>");
    Response.Write("</x:WorksheetOptions>");
    Response.Write("</x:ExcelWorksheet>");
    Response.Write("</x:ExcelWorksheets>");
    Response.Write("</x:ExcelWorkbook>");
    Response.Write("</xml>");
    Response.Write("<![endif]--> ");
    Response.Write("</head>");
    StringWriter sw = new StringWriter();
    HtmlTextWriter hw = new HtmlTextWriter(sw);
    GridView gv = new GridView();
    gv.AutoGenerateColumns = true;
    gv.DataSource = dt;
    gv.DataBind();
    gv.RenderControl(hw);
    Response.Output.Write(sw.ToString());
    Response.Flush();
    Response.End();