导出到EXCEL,第一个数字为0会被忽略掉,请问要如何设置格式
第一个数字为0会自动被EXCEL忽略掉,或者数据太长,也不能完整显示。请问要如何设置,谢谢!
<%@ page contentType="application/vnd.ms-excel; charset=gb2312" %>
<%@ page import="java.sql.*"%>
<%
response.setHeader("Content-Disposition", "attachment;filename=H1_3.xls");
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>生成</title>
</head>
<body>
<table border="1">
<TR>
<td class="xlsText"><%out.print("F203340100000");%></td>
<td class="xlsText"><%out.print("F203340300000");%></td>
<td class="xlsText"><%out.print("F203340400000");%></td>
<td><%out.print("AA");%></td>
<td><%out.print("MY");%></td>
<td><%out.print("YB");%></td>
<td><%out.print("BMY");%></td>
</TR>
</table>
<%
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@10.236.80.253:1521:chdb";
//orcl
String user="ch";
String password="ch";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from vw_h1_3@c9218";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
<table border="1">
<TR>
<td class="xlsText"><%=rs.getString(1)%> </td>
<td class="xlsText"><%=rs.getString(2)%> </td>
<td class="xlsText"><%=rs.getString(3)%> </td>
<td><%=rs.getString(4)%> </td>
<td><%=rs.getString(5)%> </td>
<td><%=rs.getString(6)%> </td>
<td><%=rs.getString(7)%> </td>
</TR>
</table>
<%}%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
[解决办法]