最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

asp.net導(dǎo)出Excel顯示中文亂碼的解決方法

 更新時(shí)間:2013年03月11日 21:20:16   作者:  
asp.net導(dǎo)出Excel顯示中文亂碼的解決方法,需要的朋友可以參考一下

復(fù)制代碼 代碼如下:

  protected void btnExcel_Click(object sender, EventArgs e)
    {
        List<bUFlow.Model.orderhistory> orderlist = dal.GetOrderList2("");
        string filename = "3g流量網(wǎng)齡升級(jí)計(jì)劃用戶表";
        string name1 = filename;
        string bname = Common.MyRequest.GetBrowserName().ToLower();
        if (bname.Contains("firefox"))
        {
        }
        else if (bname.Contains("ie"))
        {
            filename = HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8);
        }
        else
        {
            filename = HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8);
        }

        HttpResponse resp = System.Web.HttpContext.Current.Response;
        resp.Charset = "utf-8";
        resp.Clear();
        resp.AppendHeader("Content-Disposition", "attachment;filename=" + filename + ".xls");
        resp.ContentEncoding = System.Text.Encoding.UTF8;

        resp.ContentType = "application/ms-excel";
        string style ="<meta http-equiv=\"content-type\" content=\"application/ms-excel; charset=utf-8\"/>"+ "<style> .table{ font: 9pt Tahoma, Verdana; color: #000000; text-align:center;  background-color:#8ECBE8;  }.table td{text-align:center;height:21px;background-color:#EFF6FF;}.table th{ font: 9pt Tahoma, Verdana; color: #000000; font-weight: bold; background-color: #8ECBEA; height:25px;  text-align:center; padding-left:10px;}</style>";
        resp.Write(style);
        //resp.Write(ExportTable(list));
        resp.Write("<table class='table'><tr><th>" +"手機(jī)"+ "</th><th>" + "渠道" + "</th><th>" +"時(shí)間" + "</th></tr>");
        //dbVideoList = (List<subShiyongModel>)Session["dbVideoList"];
        foreach (bUFlow.Model.orderhistory model in orderlist)
        {
            resp.Write("<tr><td>" + model.phone + "</td>");
            resp.Write("<td>" + model.qudao + "</td>");
            resp.Write("<td>" + model.tm + "</td>");
            resp.Write("</tr>");
        }
        resp.Write("<table>");

        resp.Flush();
        resp.End();
    }

 


  需要注意的是編碼的問題,在輸出的時(shí)候,最好加上以下語句:
 
復(fù)制代碼 代碼如下:

<meta http-equiv="content-type" content="application/ms-excel; charset=gb2312"/>

相關(guān)文章

最新評(píng)論

泰宁县| 抚州市| 渭源县| 旅游| 吕梁市| 安国市| 治多县| 八宿县| 楚雄市| 洪湖市| 广昌县| 吉木萨尔县| 分宜县| 乡宁县| 康马县| 叙永县| 林甸县| 榆林市| 德保县| 吉林市| 晴隆县| 肇东市| 连南| 泽库县| 蒙山县| 昔阳县| 嘉禾县| 女性| 吉安市| 高阳县| 太和县| 景洪市| 常州市| 海晏县| 曲沃县| 泰州市| 宜城市| 化州市| 德令哈市| 五大连池市| 长岭县|