• 导出excel


    后台代码

         Response.Charset = "utf-8";
            Response.AppendHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode("***表.xls"));
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");//设置输出流为简体中文   
            Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。

    前端

    <html xmlns:o="urn:schemas-microsoft-com:office:office"
          xmlns:x="urn:schemas-microsoft-com:office:excel"
          xmlns="http://www.w3.org/TR/REC-html40">
    <head>
        <meta http-equiv=Content-Type content="text/html; charset=utf-8">
        <meta name=ProgId content=Excel.Sheet>
        <meta name=Generator content="Microsoft Excel 11">
        <link rel=File-List href="${savename.replace(" .xls","")}.files/filelist.xml">
        <link rel=Edit-Time-Data href="${savename.replace(" .xls","")}.files/editdata.mso">
        <link rel=OLE-Object-Data href="${savename.replace(" .xls","")}.files/oledata.mso">
        <!--[if gte mso 9]><xml>
         <o:DocumentProperties>
          <o:LastAuthor>微软用户</o:LastAuthor>
          <o:LastSaved>2012-05-30T09:29:28Z</o:LastSaved>
          <o:Version>11.5606</o:Version>
         </o:DocumentProperties>
        </xml><![endif]-->
    </head>
    <body link=blue vlink=purple>
        <table width="1200" border="1" cellspacing="0" cellpadding="0">
            <tr class="header partition">
                <th scope="col">订单号</th>
                <th scope="col">店铺名称</th>
                <th scope="col">用户名</th>
                <th scope="col">商品数量</th>
                <th scope="col">订单总金额</th>
                <th scope="col">邮费</th>
                <th scope="col">订单实付金额</th>
                <th scope="col">平台手续费</th>
                <th scope="col">店铺实收</th>
                <th scope="col">微信手续费</th>
                <th scope="col">平台实际收入</th>
                <th scope="col">收件人</th>
                <th scope="col">订单状态</th>
                <th scope="col">支付状态</th>
                <th scope="col">下单时间</th>
                <th scope="col">完成时间</th>
            </tr>
    
    
            <%foreach (var o in list)
                    { %>
            <tr class="header partition">
                <th scope="col" style="vnd.ms-excel.numberformat:@">
    
            </tr>
           <%}%>
    
    
    
        </table>
    </body>
    </html>

    顺便记录一下网上查的修改excel的格式

    文本:vnd.ms-excel.numberformat:@ 

    日期:vnd.ms-excel.numberformat:yyyy/mm/dd 

    数字:vnd.ms-excel.numberformat:#,##0.00 

    货币:vnd.ms-excel.numberformat:¥#,##0.00

    百分比:vnd.ms-excel.numberformat: #0.00% 

    加到style里

  • 相关阅读:
    cmd的有趣的操作
    Hbuilder 【App开发准备】
    Hbuilder 【app设置,云打包】
    U盘测试和查明真伪
    luogu P2962 [USACO09NOV]灯Lights 高斯消元
    Nowcoder牛客网NOIP赛前集训营-提高组(第六场)
    Codeforces Round #517 (Div. 2)
    code——tmp
    bzoj3329: Xorequ 数位DP
    bzoj3033: 太鼓达人 欧拉路径
  • 原文地址:https://www.cnblogs.com/long7long/p/11024420.html
Copyright © 2020-2023  润新知