在jsp文件开始处添加一下代码即可:
<%response.setContentType("application/vnd.ms-excel");%>
<%response.setHeader("Content-Disposition", "attachment;filename=\""+new String("资金信息表.xls".getBytes(),"ISO-8859-1")+"\"");%>

解决方案 »

  1.   

    给你个我编的
    <%
    dim conn
    dim strSql
    dim intControlNo
    Dim rsset dbconnection=Server.CREATEOBJECT("ADODB.CONNECTION")
    DBPath = Server.MapPath("user.mdb")
    dbconnection.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
      Response.CacheControl = "Private"
      Response.ContentType = "application/vnd.ms-excel"
      Response.AddHeader "content-disposition","inline;filename=N"
      
        SQL="SELECT USER_ID,USER_NAME,USER_PASSWD,USER_INFO FROM USER"
        SET uplist=Server.CreateObject("ADODB.RecordSet")
        uplist.CursorLocation = 3
        uplist.open SQL,dbconnection,1,3  
    %>
    <HTML>
    <HEAD>
    <TITLE>情報共有Web</TITLE>
    <meta http-equiv="Content-Type" content="application/vnd.ms-excel; charset=GB_2312">
    </HEAD><BODY>
    <DIV style="HEIGHT: 0px; LEFT: -200px; POSITION: absolute; TOP: -200px; VISIBILITY: visible; WIDTH: 0px; Z-INDEX: 1"></DIV>
    <Table border>
    <TR>
    <TD BGCOLOR=#C0C0C0 VALIGN="bottom"><FONT FACE="仿宋_GB2312"><B>序列号</B></FONT></TD>
    <TD BGCOLOR=#C0C0C0 VALIGN="bottom"><FONT FACE="仿宋_GB2312"><B>用户ID</B></FONT></TD>
    <TD BGCOLOR=#C0C0C0 VALIGN="bottom"><FONT FACE="仿宋_GB2312"><B>用户姓名</B></FONT></TD>
    <TD BGCOLOR=#C0C0C0 VALIGN="bottom"><FONT FACE="仿宋_GB2312"><B>用户密码</B></FONT></TD>
    <TD BGCOLOR=#C0C0C0 VALIGN="bottom"><FONT FACE="仿宋_GB2312"><B>用户信息</B></FONT></TD>
    </TR>
    <%
          If uplist.RecordCount <> 0 Then      
             if uplist.EOF = true then
    uplist.MoveLast
    uplist.MoveFirst
     end if

       intRecordCount=0
     
     While not uplist.EOF 
      intRecordCount=intRecordCount + 1
    %>
    <TR VALIGN="top">
    <TD ALIGN="left"><FONT FACE="仿宋_GB2312"><%=intRecordCount%></FONT></TD>
    <TD ALIGN="left"><FONT FACE="仿宋_GB2312"><%=uplist.Fields("USER_ID")%></FONT></TD>
    <TD ALIGN="left"><FONT FACE="仿宋_GB2312"><%=uplist.Fields("USER_NAME")%></FONT></TD>
    <TD ALIGN="left"><FONT FACE="仿宋_GB2312"><%=uplist.Fields("USER_PASSWD")%></FONT></TD>
    <TD ALIGN="left"><FONT FACE="仿宋_GB2312"><%=uplist.Fields("USER_INFO")%></FONT></TD>
    </TR><%
    uplist.MoveNext
    Wend
         End If
         uplist.Close
    %>
    </Table><FONT SIZE=-1><I>
    <FONT SIZE=+0></I>
    </BODY>
    </HTML>
    <%
     set uplist = nothing
     dbconnection.close
    %>
      

  2.   

    上面那个,我用的是access数据库,不是很麻烦!~~
      

  3.   

    可以试试JavaCellReport  http://www.javatoolsoft.com/cn
    一个java版本的Excel.类似于Excel的基本操作,使各领域熟悉Excel的用户能快速掌握JavaCellReport报表系统。 
    创新的缓存机制使JavaCellReport能够显示拥有超大数据量的报表。(这是一个好的报表工具最基本的特征) 
    易用的数据绑定功能,可以让用户只需要简单的用鼠标拖放,就可以绑定数据到表格和图表。 
    通过服务器端报表Reportlet,能够让用户做出功能极其强大的网络报表系统。 
    利用JDBC,可以连接Oracle, DB2, SQLServer, MySQL, Access等一切支持JDBC的主流数据库。 
    ...  
     
    http://www.javatoolsoft.com/cn
      

  4.   

    绝对要用POI的HSSF子项目。相信我
      

  5.   

    把该页的ContentType设为excel即可
      

  6.   

    过分阿,这种东西还用什么POI,看清楚搂住的问题后再回答。
    你照“迷路飞羊”的去做,不成功我给楼主分。