发布网友 发布时间:2022-04-22 08:23
共1个回答
热心网友 时间:2022-06-18 13:30
不用这么麻烦的 直接用TABLE就行了,就是在JSP头文件要稍微改一下,我都是这么弄的 我给你看个我做的粗糙点,大致意思有了 <%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" import="java.util.Vector" errorPage="" %> <% response.setContentType("application/vnd.ms-excel;charset=gb2312"); response.setHeader("Content-disposition","inline; filename=ywl.xls"); %> 导出EXCEL表格 业务所有数据 <%Connection con= null; Statement stmt= null; ResultSet rs = null; ResultSet rs1 = null; ResultSet rs2 = null; ResultSet rs3 = null; ResultSet rs4 = null; try{ Class.forName("com.mysql.jdbc.Driver"); String url ="jdbc:mysql://localhost:3306/xnwxt?user=root&password=87601401&useUnicode=true&characterEncoding=GB2312"; con =DriverManager.getConnection(url); stmt=con.createStatement(); String select3="select * from xnwxt order by id desc "; //////////////////////////////////////////////// rs3=stmt.executeQuery(select3); out.print("<table align=center>"); out.print("<tr>"); out.print("<td width=80><strong>"); out.print( "上报时间") ; out.print("</strong></td>"); out.print("<td width=80><strong>"); out.print( "上报渠道") ; out.print("</strong></td>"); out.print("<td width=80><strong>"); out.print( "上报人") ; out.print("</strong></td>"); out.print("<td width=80><strong>"); out.print( "号码1") ; </strong></table>