Excel生成和讀取(原創)

1、jxl包(JAVA EXCEL API)。
2、poi包(Jakarta POI API ),apache的開源包。
3、iText包,對pdf處理很好。
4、當然,有興趣你可以自己寫。
用過jxl,和使用數據庫的ResultSet差不多。

另:
在線打開Excel
try{
File f = new File(path);
BufferedInputStream br = new BufferedInputStream(new FileInputStream(f));
byte[] buf = new byte[1024];
int len = 0;
response.reset(); //非常重要
response.setContentType("application/vnd.ms-excel");
OutputStream outStream = response.getOutputStream();
while((len = br.read(buf)) >0)
outStream.write(buf,0,len);
br.close();
outStream.close();
}catch(Exception e){
e.printStackTrace();
out.println("下載打開出錯");
return ;
}

下載用SmartUpload 包
SmartUpload su = new SmartUpload();
su.initialize(config, request, response);
su.setContentDisposition(null);
su.downloadFile(path, "", fileTitle+".xls");
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章