zoukankan      html  css  js  c++  java
  • 导出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里

  • 相关阅读:
    【BZOJ2844】albus就是要第一个出场 高斯消元求线性基
    Python入门之面向对象module,library,package之间区别
    Python入门之字典的操作详解
    Python Web学习笔记之TCP/IP协议原理与介绍
    Python Web笔记之高性能网络编程
    Python Web学习笔记之面试TCP的15个问题
    Python Web学习笔记之TCP/IP、Http、Socket的区别
    Python Web学习笔记之TCP、UDP、ICMP、IGMP的解释和区别
    Python Web学习笔记之IGMP和ICMP的差别
    Python设计模式之单例模式
  • 原文地址:https://www.cnblogs.com/long7long/p/11024420.html
Copyright © 2011-2022 走看看