国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 石门县| 独山县| 乌拉特后旗| 陆丰市| 鄄城县| 亳州市| 柘荣县| 广河县| 瑞昌市| 上蔡县| 手机| 乌海市| 大新县| 达州市| 涟水县| 天津市| 隆林| 临高县| 饶阳县| 大宁县| 永州市| 宜都市| 长阳| 彩票| 独山县| 奉化市| 庆安县| 商河县| 盈江县| 八宿县| 石屏县| 大余县| 隆回县| 儋州市| 获嘉县| 新田县| 昆明市| 阜宁县| 自贡市| 定州市| 新丰县|