|
需要两个jar包>package ptobu_java; import java.io.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import jxl.*;
import jxl.format.UnderlineStyle;
import jxl.write.*;
public> private Connection conn = null;
public static void main(String[] args) {
expExecl t = new expExecl();
t.getConn();
t.excel("福建");
//t.eExcel();
}
public void excel(String filename){
Statement st = null;
ResultSet rs = null;
WritableWorkbook wwb;
try {
wwb = Workbook.createWorkbook(new File("d://"+filename+".xls"));
SimpleDateFormat formatter= new SimpleDateFormat ("yyyy-MM-dd hh:mm:ss");
java.util.Calendar currentTime = java.util.Calendar.getInstance();
String dateString = formatter.format(currentTime.getTime());
for (int type=8;type>=1;type--){
System.out.println(dateString+"开始第"+type+"类");
String sheet = "";
String condition="";
String> if(type==1){
sheet="第一类";
title="重户口";
condition="350101";
}if(type==2){
sheet="第二类";
title="出生或补录";
condition="350102";
}if(type==3){
sheet="第三类";
title="33333333333";
condition="350103";
}if(type==4){
sheet="第四类";
title="444444444444";
condition="350104";
}if(type==5){
sheet="第五类";
title="5555555555555555";
condition="11";
}if(type==6){
sheet="第六类";
title="6666666666666";
condition="350104";
}if(type==7){
sheet="第七类";
title="77777777777777777";
condition="33";
}if(type==8){
sheet="第八类";
title="888888888888";
condition="350103";
}
WritableSheet ws = wwb.createSheet(sheet, 0);
Label caption1 = new Label(0, 0,> ws.mergeCells(0, 0, 10, 1);
ws.addCell(caption1);
Label caption41 = new Label(0, 2, "G");
Label caption42 = new Label(1, 2, "F0");
Label caption43 = new Label(2, 2, "系统码");
Label caption44 = new Label(3, 2, "设备码");
ws.addCell(caption41);
ws.addCell(caption42);
ws.addCell(caption43);
ws.addCell(caption44);
st = this.conn.createStatement();
rs = st.executeQuery("select * from a_test where c='"+condition+"'");
int cnt = rs.getMetaData().getColumnCount();
int row = rs.getRow();
// System.out.println(cnt);
// System.out.println(row);
Object obj = null;
int j=3;
while(rs.next()){
for (int i=1;i |
|
|