关于Exce报表没有边框的问题-解决办法(修改html后缀方法)

来源:互联网 发布:你怕是有点迷网络意思 编辑:程序博客网 时间:2024/05/16 01:08
<%@ page language="java" import="java.util.*,com.qhkj.car.model.*" pageEncoding="utf-8"%><%@ page import="java.text.SimpleDateFormat"%><% Date dt=new Date();SimpleDateFormat fmt=new SimpleDateFormat("yyyyMMdd");String m=fmt.format(dt);String na=new String("汇总统计".getBytes(),"iso8859-1");String fileName =na+m+".xls";//下载对话框的保存文件名 response.setHeader("Content-disposition", "attachment; filename="+ fileName); %><%@ include file="../util/tags.jsp" %>

<%List list_fuWuZhongLei2 =(List)request.getAttribute("fuWuShangFuWuZhongLei2_List"); //大种类 List list_fuWuZhongLei =(List)request.getAttribute("fuWuShangFuWuZhongLei_List");//小种类 %><% for(int i=0;i<%}%><% for(int i=0;i<% } } }%><%--*****************名字是类名+View --%><%List list_FWS = (List)request.getAttribute("fuWuShangView_List");for(int i = 0;i<% for(int j=0;j<% } } }%><%}%>
优惠折扣(金额/折扣幅度/免费)
公司信息<%=list_fuWuZhongLei2.get(i).getFuWuZhongLei2() %>
序号公司名称地址电话公司类型<%=list_fuWuZhongLei.get(j).getFuWuZhongLei() %>
<%=fuWuShang2.getId() %><%=fuWuShang2.getXiangXiDiZhi()%><%=fuWuShang2.getChangShangMingCheng()%><%=fuWuShang2.getChangShangDianHua()%><%=fuWuShang2.getFuWuShangLeiBieName()%><%=flagtd%>

 

基本形式如上,下面的head部分是给excel添加边框,<x:Name>Sheet2</x:Name>是页脚的名字,

在这里有3个,Sheet1,Sheet2,Sheet3,名字可以自己改,也可以干掉两个,导出的原则是另一页跳转此页自动下载excel

 

<%@ page language="java" import="java.util.*,com.qhkj.car.model.*" pageEncoding="utf-8"%>
<%@ page import="java.text.SimpleDateFormat"%>
<% 
 Date dt=new Date();
SimpleDateFormat fmt=new SimpleDateFormat("yyyyMMdd");
String m=fmt.format(dt);
String na=new String("汇总统计".getBytes(),"iso8859-1");
String fileName =na+m+".xls";//下载对话框的保存文件名
 response.setHeader("Content-disposition", "attachment; filename="+ fileName); 
%>
<%@ include file="../util/tags.jsp" %>
<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">
<title>导出清单</title>
<!--[if gte mso 9]><xml>
 <x:ExcelWorkbook>
  <x:ExcelWorksheets>
   <x:ExcelWorksheet>
    <x:Name>Sheet1</x:Name>
    <x:WorksheetOptions>
     <x:DefaultRowHeight>285</x:DefaultRowHeight>
     <x:Selected/>
     <x:Panes>
      <x:Pane>
       <x:Number>3</x:Number>
       <x:ActiveRow>3</x:ActiveRow>
       <x:ActiveCol>2</x:ActiveCol>
      </x:Pane>
     </x:Panes>
     <x:ProtectContents>False</x:ProtectContents>
     <x:ProtectObjects>False</x:ProtectObjects>
     <x:ProtectScenarios>False</x:ProtectScenarios>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
   <x:ExcelWorksheet>
    <x:Name>Sheet2</x:Name>
    <x:WorksheetOptions>
     <x:DefaultRowHeight>285</x:DefaultRowHeight>
     <x:ProtectContents>False</x:ProtectContents>
     <x:ProtectObjects>False</x:ProtectObjects>
     <x:ProtectScenarios>False</x:ProtectScenarios>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
   <x:ExcelWorksheet>
    <x:Name>Sheet3</x:Name>
    <x:WorksheetOptions>
     <x:DefaultRowHeight>285</x:DefaultRowHeight>
     <x:ProtectContents>False</x:ProtectContents>
     <x:ProtectObjects>False</x:ProtectObjects>
     <x:ProtectScenarios>False</x:ProtectScenarios>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
  </x:ExcelWorksheets>
  <x:WindowHeight>9600</x:WindowHeight>
  <x:WindowWidth>15075</x:WindowWidth>
  <x:WindowTopX>480</x:WindowTopX>
  <x:WindowTopY>90</x:WindowTopY>
  <x:ProtectStructure>False</x:ProtectStructure>
  <x:ProtectWindows>False</x:ProtectWindows>
 </x:ExcelWorkbook>
</xml><![endif]-->
</head>
<body>
<%List<FuWuShangFuWuZhongLei2>  list_fuWuZhongLei2 =(List<FuWuShangFuWuZhongLei2>)request.getAttribute("fuWuShangFuWuZhongLei2_List"); //大种类
     List<FuWuShangFuWuZhongLei>  list_fuWuZhongLei =(List<FuWuShangFuWuZhongLei>)request.getAttribute("fuWuShangFuWuZhongLei_List");//小种类
     %>
      <table class="tableAll" width="100%" style="font-size: 9pt;" >
       <tr><td align="center" colspan="<%=list_fuWuZhongLei.size()+5 %>">优惠折扣(金额/折扣幅度/免费)</td></tr>
       <tr>
        <td></td>
        <td colspan="4" align="center">公司信息</td>
        <% for(int i=0;i<list_fuWuZhongLei2.size();i++){
         int n=0;
         for(int j=0;j<list_fuWuZhongLei.size();j++){
          String fid2=list_fuWuZhongLei2.get(i).getId()+"";
          String fid=list_fuWuZhongLei.get(j).getIdFuWuZhongLei2()+"";
          if(fid.equals(fid2)){
           n++;
          }
         }
         %>
         
         <td align="center" colspan="<%=n %>"> <%=list_fuWuZhongLei2.get(i).getFuWuZhongLei2() %> </td>
        <%}%>
       </tr>
       <tr>
        <td>序号</td><td>公司名称</td>    <td>地址</td>   <td>电话</td>    <td>公司类型</td>
        <% for(int i=0;i<list_fuWuZhongLei2.size();i++){
         for(int j=0;j<list_fuWuZhongLei.size();j++){
          String fid2=list_fuWuZhongLei2.get(i).getId()+"";
          String fid=list_fuWuZhongLei.get(j).getIdFuWuZhongLei2()+"";
          if(fid.equals(fid2)){
           %><td><%=list_fuWuZhongLei.get(j).getFuWuZhongLei() %></td><%
          }
         }
        }%>
       </tr>
<%--*****************名字是类名+View --%>
   <%
    List<FuWuShangView>  list_FWS = (List<FuWuShangView>)request.getAttribute("fuWuShangView_List");
    for(int i = 0;i<list_FWS.size();i++)
    {
     FuWuShangView fuWuShang2 = list_FWS.get(i);
    
    %>
    
        <tr class="tr_<%=fuWuShang2.getId() %>" >
         <td  width="115">
         <%=fuWuShang2.getId() %>
         </td>
         <td><%=fuWuShang2.getXiangXiDiZhi()%></td>
         <td><%=fuWuShang2.getChangShangMingCheng()%></td>
         <td><%=fuWuShang2.getChangShangDianHua()%></td>
         <td ><%=fuWuShang2.getFuWuShangLeiBieName()%></td>
         <% for(int j=0;j<list_fuWuZhongLei2.size();j++){
         for(int k=0;k<list_fuWuZhongLei.size();k++){
          if(list_fuWuZhongLei2.get(j).getId().equals(list_fuWuZhongLei.get(k).getIdFuWuZhongLei2())){
           String zhongLeiHeFeiYong = fuWuShang2.getZhongLeiHeFeiYong();
           String[] zhongLeiHeFeiYongArr = zhongLeiHeFeiYong.split(",");
           String flagtd = "";
           for(int z = 0;z<zhongLeiHeFeiYongArr.length;z=z+2)
           {
             if((list_fuWuZhongLei.get(k).getId()+"").equals(zhongLeiHeFeiYongArr[z].trim()))
             {
              flagtd = zhongLeiHeFeiYongArr[z+1];
             }
            }%><td><%=flagtd%></td><%
          }
         }
        }%>
        </tr><%}%>
      </table></body>
</html>