excel文件的页面(jsp)输出!

<%@ page language="java" contentType="text/html; charset=GBK"  pageEncoding="GBK"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.ecside.org" prefix="ec"%>
<%@ page import="java.util.Date"%>
<%@ page import="java.text.SimpleDateFormat"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@page import="java.util.Calendar,java.util.*,
    java.io.*,jxl.*,javax.servlet.ServletContext"
%>
<html >
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=MS950">
<link rel="stylesheet" Content-type="text/css" href="../../css/webber.css">
<script language="JavaScript" src="lib/prototype/prototype.js"></script>
<%
String fileName = (String) request.getAttribute("fileName");
%>
<script language="JavaScript">
 function exportExcel()
{
 var url =  "download.jsp?fileName=" + "<%=fileName%>";
 window.location.href(url);
}
 
</script>

<title>各功能访问情况比例统计</title>

<jsp:include page="../common_head.jsp" flush="true" />


</head>

<body >
<table align=center class=listFrame cellspacing=1 cellpadding=0
 width="85%">
 <tbody>
  <tr align="right">
   <td ><INPUT
    type="button" class="funButton" value=" 导出Excel " οnclick="exportExcel()">&nbsp;&nbsp;&nbsp;</td>
  </tr>
  <tr>
   <td   colspan=21
    style="font-size: 16px; line-height: 30px; BACKGROUND-COLOR: #bddbf7"><b><c:out
    value="${title}" /></b></td>
  </tr>
 </tbody>
</table>
<div id="div1" style="scroll:auto;overflow:auto;width:100%;letter-spacing:0.2em;height:450px;top:100px;left:50px">
<table align=center class=listFrame cellspacing=1 cellpadding=0 width="85%">
     <%
      fileName = (String) request.getAttribute("fileName");
      String filePath = application
        .getRealPath("/report/"
        + fileName);
      FileInputStream finput = new FileInputStream(filePath);
      Workbook wbook;
      wbook = Workbook.getWorkbook(finput);
      Sheet wsheet = (Sheet) wbook.getSheet(0);
      finput.close();
      Cell[] rowcell = null;
      Cell cell = null;
      short i = 0;
      short y = 0;
      for (i = 0; i < wsheet.getRows(); i++) {
       out.println("<tr>");
       rowcell = wsheet.getRow(i);

       for (y = 0; y < rowcell.length; y++) {
        cell = rowcell[y];
        out.print("<td  class=listContent>");
        cell.getCellFormat().getFont().getBoldWeight();
        //字体宽度
        int bw = cell.getCellFormat().getFont().getBoldWeight();
        
        if (null != cell) {
         if(bw == 700)
            {
          out.print("<b>"+cell.getContents().replace("  ","&nbsp;&nbsp;")+"</b>");
            }else{
             out.print(cell.getContents().replace("  ","&nbsp;&nbsp;"));
            }
         
        }

        out.println("</td>");
       }
       out.println("</tr>");
      }
     %>
</table>
</div>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值