当前位置:编程学习 > C#/ASP.NET >>

用360浏览器导出Excel时导出函数执行了2次且页面自动关闭了

在IE浏览器不存在这个问题,就在360用他本身的下载器下载就会出现这样的问题。求解
ImageButton是在UpdatePanel中的也用了
 <Triggers>
<asp:PostBackTrigger ControlID="btnExport" />
</Triggers>

 /// <summary>
    /// 生成Excel
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnToExcel_Click(object sender, EventArgs e)
    {
        string templetFilePath = Server.MapPath("~/Web/Template/快递对账(明细).xls");
        //输出路径
        string outFileName =  "快递对账(明细).xls";
        string sPath = Server.MapPath("~/Web/Temp/").ToString();
        string outputFilePath = sPath + outFileName;

        try
        {
            if (!File.Exists(templetFilePath))
            {
                ScriptManager.RegisterStartupScript(this, Page.GetType(), "display", "alert('指定路径的Excel模板文件不存在!');", true);
                return;
            }
            if (File.Exists(outputFilePath))
            {
                File.Delete(outputFilePath);
            }
            //---------------------------------zhoujie-----------------------------
            else
            {
                //复制模板文件
                File.Copy(templetFilePath, outputFilePath, true);
            }

            //object missing = Missing.Value;

            //取得excel文件
            FileStream sourcefile = new FileStream(templetFilePath, FileMode.Open, FileAccess.Read);
            //取得workbook
            HSSFWorkbook hssfworkbook = new HSSFWorkbook(sourcefile);
            //取得sheet
            Sheet sheet = hssfworkbook.GetSheetAt(0);

            sheet.ForceFormulaRecalculation = true;
            FileStream objectFile = new FileStream(outputFilePath, FileMode.Create);
            hssfworkbook.Write(objectFile);
            sourcefile.Close();
            objectFile.Close();

            FileInfo fFile = new FileInfo(outputFilePath);
            HttpResponse response = HttpContext.Current.Response;
            string fileName = HttpContext.Current.Server.UrlEncode(fFile.Name);
            response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
            response.Charset = "UTF-8";
            response.ContentEncoding = System.Text.Encoding.Default;
            response.ContentType = "application/ms-excel";

            response.Clear();
            response.WriteFile(outputFilePath);
            response.End();
        }
        catch (Exception ex)
        {
            ScriptManager.RegisterStartupScript(this, Page.GetType(), "display", "alert('" + ex.Message + "Excel生成失败');", true);
        }
    }


--------------------编程问答-------------------- 360的内核使用的是IE内核。 
就目前的市场占有份额来说,360游览器微乎其微。360上出现问题,一般没必要给自己找麻烦去寻找为什么。 --------------------编程问答--------------------
引用 1 楼 johooLee 的回复:
360的内核使用的是IE内核。 
就目前的市场占有份额来说,360游览器微乎其微。360上出现问题,一般没必要给自己找麻烦去寻找为什么。


360浏览器的下载器是这样的变态,他的下载模式可选 , 但是你不能强制用户 ,
想办法解决呗  

说360浏览器市场占有份额微乎其微,这个 。。。。  --------------------编程问答-------------------- 不好意思,呵呵,没说具体。
在国际来说,360游览器不算多,但在国内来说,他的占有份额还是很高的。
--------------------编程问答-------------------- 有没有办法解决 --------------------编程问答-------------------- ie行,360就不行,360是基于ie开发的,那是不是360对ie的支持不够完整 --------------------编程问答-------------------- 楼主这个问题解决了吗?我也遇到了
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,