求代码,谢谢。。就是写一个jsp程序实现orcale数据库中的某个表数据导出功能,生成文件为excel或者txt都行,谢谢!!!!
解决方案 »
- ASP+ORACLE 移植问题,Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
- 使用data link 连接远程数据库同步遇到的问题
- 请问谁有 oracle 7 for solaris 啊, 网上没有的下载.
- 请问创建物化视图时,如何才能够不产生日志
- 100分!oracle服务自动停止的问题
- Oracle连接问题,太离奇了,望高手相助!
- 明明创建了表空间,但是在创建用户时却提示 ORA-00959: 表空间'MY_TEST_DEF'不存在
- 如何将数据从SQL Server 2000中导入到oracle
- 有三个表a,b,c 分别有两个字段人数,地区。如何联合统计各个地区人数??
- 想清空一个表中的所有数据,怎么写啊。
- odbc for oracle问题(windows环境)
- 存储过程传入参数的问题
package com.testing.Service;import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableCellFormat;
import jxl.write.WritableFont;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
import jxl.write.biff.RowsExceededException;
/**
* description: Used to generate a excel file, which store the latest proxy ID map.
* @author Shawn Xiao
* Jun 29, 2010 15:48:47 PM
*/
public class GenProxyIDMapExtractor {
public void writeProxyIDMapExcel() throws RowsExceededException,
WriteException, SQLException, IOException { String fileName = "c:/ProxyIDMap.csv"; //create the workbook and sheet
WritableWorkbook wwb = Workbook.createWorkbook(new File(fileName));
WritableSheet ws = wwb.createSheet(("Sheet" + "1"), 0); // set the font
WritableFont wf = new WritableFont(WritableFont.TIMES, 11, WritableFont.BOLD, false);
WritableCellFormat wcfF = new WritableCellFormat(wf); wcfF.setAlignment(jxl.format.Alignment.CENTRE);
wcfF.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE); // generate the Header
generateHeader(ws, wcfF); List list = new GenProxyIDMapQuery().getProxyIDMap_temp();
wcfF = new WritableCellFormat();
int index = 1;
for (int i = 0; i < list.size(); i++) {
ProxyIDmapData test = (ProxyIDmapData)list.get(i);
ws.setColumnView(0, 20);
ws.setColumnView(1, 20);
ws.setColumnView(2, 20);
ws.setColumnView(3, 20); Label data1 = new Label(0, index, ("" + test.getAs_of_date()), wcfF);
Label data2 = new Label(1, index, ("" + test.getSec_id()), wcfF);
Label data3 = new Label(2, index, ("" + test.getProxy_id()), wcfF);
Label data4 = new Label(3, index, ("" + test.getData_source()), wcfF);
ws.addCell(data1);
ws.addCell(data2);
ws.addCell(data3);
ws.addCell(data4);
index++;
}
wwb.write();
wwb.close();
}
/**
* generate the Header for the file
*/
private void generateHeader(WritableSheet ws, WritableCellFormat wcfF) throws WriteException, RowsExceededException {
Label labelCF1 = new Label(0, 0, "as_of_date", wcfF);
Label labelCF2 = new Label(1, 0, "sec_id", wcfF);
Label labelCF3 = new Label(2, 0, "proxy_id", wcfF);
Label labelCF4 = new Label(3, 0, "data_source", wcfF); // bond the values
ws.addCell(labelCF1);
ws.addCell(labelCF2);
ws.addCell(labelCF3);
ws.addCell(labelCF4);
}
/**
* Main class used to testing.
*/
public static void main(String[] args) throws RowsExceededException, WriteException, SQLException, IOException {
new GenProxyIDMapExtractor().writeProxyIDMapExcel();
}
}
刚好昨天写了个简单的。