JSP Operation EXECL Analysis
Last Update:2017-02-28
Source: Internet
Author: User
JS <%@ page contenttype= "text/html; charset=gb2312 "language=" java import= "java.sql.*"%>
<%@ page import= "jxl.*"%>
<%@ page import= "jxl.write.*"%>
<%@ page import= "java.io.*"%>
<%@ page import= "java.util.*"%>
<jsp:usebean id= "conn" class= db. DbConnection "scope=" page/>
<%
String sql= (String) session.getvalue ("SQL");
String apti= (String) session.getvalue ("Apti");
Select Companyapti.companyid,companyapti.companytype,companyapti.c
Ompanyname,companyinfo.province,companyinfo.city, Companyinfo.address,
Companyinfo.connectman,companyinfo.mobile,companyinfo.tel,companyinfo.telephone
%>
<%
try{
Writableworkbook workbook = Workbook.createworkbook (New File (Request.getrealpath ("/") + "/mis/" + "/Enterprise information. xls"));
Create an Excel worksheet
Writablesheet Sheet=workbook.createsheet ("Enterprise Information", 0);
Jxl.write.WritableSheet ws = Wwb.createsheet ("Test Sheet 1", 0);
Set fonts and Formatting
Writer data
while (Rs.next ()) {//while start
for (int i=1;i<=23;i++) {
Username=rs.getstring (1). Equals ("0")? "": rs.getstring (1). Trim ();
Username= "yzhxy2002";
Label L=new label (0, 0, username);
Sheet.addcell (l);
Jxl.write.Label LABELC = new Jxl.write.Label (1, 0, "This is a Label cell");
Sheet.addcell (LABELC);
Label N=null,p=null,c=null,a=null,m=null,s=null,t=null,t1=null,t2=null;
String companyid= "", apti= "", Aptiname= "", Companyname= "", companytype= "", province= "",
City= ", address=" ", connectman=" ", mobile=" ", tel=" ", telephone=" ";
ResultSet Rs=null;
Out.print (SQL);
Rs=conn.executequery (SQL);
int i=0;
while (Rs.next ()) {
Inquiry Qualification
StringTokenizer fenxi=new StringTokenizer (rs.getstring ("Companytype"), "-");
while (Fenxi.hasmoretokens ()) {
Companytype=fenxi.nexttoken (). toString ();
String sql0= "SELECT * from Aptitype where typeid= '" +companytype+ "";
ResultSet rs0=conn.executequery (sql0);
if (Rs0.next ()) {
Aptiname=new String (Rs0.getstring ("TypeName"). GetBytes ("iso8859-1"));
}
Apti=aptiname+ "-" +APTI;
}//while
//
N=new Label (0,i,new String (rs.getstring ("CompanyName"). GetBytes ("iso8859-1"));
P=new Label (1,i,new String (rs.getstring ("province"). GetBytes ("iso8859-1"));
C=new Label (2,i,new String (rs.getstring ("City"). GetBytes ("iso8859-1"));
A=new Label (3,i,new String (rs.getstring ("Address"). GetBytes ("iso8859-1"));
M=new Label (4,i,new String (rs.getstring ("Connectman"). GetBytes ("iso8859-1"));
S=new Label (5,i,rs.getstring ("mobile"));
T=new Label (6,i,rs.getstring ("tel"));
T1=new Label (7,i,rs.getstring ("Telephone"));
T2=new Label (8,I,APTI);
Sheet.addcell (n); Sheet.addcell (P); Sheet.addcell (c);
Sheet.addcell (a); Sheet.addcell (m); Sheet.addcell (s); Sheet.addcell (t); Sheet.addcell (t1);
Sheet.addcell (T2);
i++;
Apti= "";
}
Out.print (Rs.get (0,2));
Second table
Writablesheet Sheet1=workbook.createsheet ("Qualification Information", 1);
Companytype
Workbook.write ();
Workbook.close ();
// }
}//while End
}
catch (Exception e)
{
E.printstacktrace ();
}
%>
<title> Operations Excel Table </title>
<body>
<table width= "653" border= "0" align= "center" cellpadding= "0" cellspacing= "0" >
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<TD height= "><div" align= "center" ><a href= "Enterprise information. xls" >
Download Enterprise Information </a ></div></td>
</tr>
<tr>
<td><br>
</td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</body>