String name =
"xls\\hetongdaoqitixing.xls";
File file =
new File(name);
try {
Workbook wb = Workbook.getWorkbook(file);
WritableWorkbook book = Workbook.createWorkbook(
new File(
"xlsd\\hetongdaoqitixing.xls")
WritableSheet sheet = book.getSheet(0);
int cols = sheet.getColumns();
DB db =
new DB();
ResultSet rs = db.getCon().createStatement().executeQuery(
"select * from fcb_hetong where datediff(day,getDate(),止租日期)<=30 and datediff(day,getDate(),止租日期)>=0 and 合同状态='生效合同'");
while (rs.next()) {
int rows = sheet.getRows();
for (
int i = 0; i < cols; i++) {
sheet.addCell(
new Label(i,rows,rs.getString(i + 1).toString()));
}
}
book.write();
System.
out.println(
"成功");
book.close();
wb.close();
Runtime run=Runtime.getRuntime();
run.exec(
"C:\\Program Files\\Microsoft Office\\OFFICE11\\EXCEL.EXE xlsd\\hetongdaoqitixing.xls");
}
catch (Exception e1) {
e1.printStackTrace();
}