国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

asp.net中Table生成Excel表格的方法

2024-07-10 12:48:07
字體:
供稿:網(wǎng)友

本文實例講述了asp.net中Table生成Excel表格的方法。。

具體實現(xiàn)方法如下:

代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link href="/Css/Balance.css" rel="stylesheet" />
    <title></title>
    <script runat="server">
        protected void writeXls(object sender, EventArgs e)
        {
            Response.Clear();
            Response.Buffer = true;
            Response.ContentType = "application/vnd.ms-excel.numberformat:@";
            this.EnableViewState = false;
            Response.Charset = "UTF-8";
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");//設(shè)置輸出流為簡體中文 
            Response.AppendHeader("Content-Disposition", "attachment;filename=" + Title + ".xls");
            Response.Write(printHid.Value);
            Response.End();
        }
    </script>
</head>
<body>
   <form id="form1" runat="server">
    <asp:HiddenField ID="printHid" runat="server" />
      <button onclick="getHtmltoValue()" >生成excel</button>
     <script type="text/javascript">
       function getHtmltoValue() {
          document.getElementById("<%=printHid.ClientID%>").value = document.getElementById("printDiv").innerHTML;
      }
   </script>

       <table >
            .......
        </table>
    </form>
</body>
<html>

希望本文所述對大家的asp.net程序設(shè)計有所幫助。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 塘沽区| 宁德市| 崇文区| 碌曲县| 克东县| 黔江区| 麻江县| 清水县| 山阳县| 广宁县| 长乐市| 定安县| 琼结县| 安新县| 乌恰县| 九台市| 宁津县| 大同市| 邵阳县| 晴隆县| 东台市| 鄯善县| 普定县| 山东| 苏尼特右旗| 平原县| 保靖县| 武清区| 丰城市| 洛阳市| 洪江市| 门头沟区| 井陉县| 乌拉特中旗| 资源县| 牟定县| 拜城县| 龙江县| 新邵县| 湘潭县| 克拉玛依市|