- 3
- 0
- 约7.89千字
- 约 6页
- 2017-02-16 发布于江苏
- 举报
代码:
response.setCharacterEncoding(utf8);
int totalcount=agentService.queryCount(map);//查询记录总数
try {
OutputStream outputStream = response.getOutputStream();
String title=影楼充值数据.xls;//excel文件名
byte[] content=findExcelData(totalcount,map,影楼充值数据);//转字节流 totalcount 总数; map 参数 ; 最后一个是sheet名称
response.setContentType(application/x-msdownload);
response.setContentLength(content.length);
response.setHeader(Content-Disposition, attachment;filename=+ new String(title.getBytes(utf-8), ISO-8859-1));
outputStream.write(content);
outputStream.flush();
outputStream.close();
}catch (IOException e) {
LOGGER.error(IOException:, e.fillInStackTrace());
}
findExcelData 方法
public byte[] findExcelData(int count,Map map,String title) {
int start=0;
int limit=2000;//一个sheet存60000条数据,超过6W条新建新sheet
ListStudioSeriesPrice list = null;
ByteArrayOutputStream out = new ByteArrayOutputStream();
ExcelWriter writer = null;
try {
writer = new ExcelWriter(out);
ExcelWriter.Sheet sheetAct = null;
String [] excelHead= {影楼名称,时间,价格,套数,类型,代理商,套系名称};
int sizes=(count/limit)+(count%limit0?1:0);
for(int j=0;jsizes;j++){
//大批量数据采用分页写入数据
map.put(start, j*limit);
map.put(limit, limit);
if(j%30==0){
int num=j/30+1;
sheetAct=createExcelHead(sheetAct,writer,excelHead,title+num);
}
list=agentService.queryExportData(map);
if(j5){
findExcelData(j*limit,list,sheetAct);
}else{
int num=j/5;
findExcelData((j-num*5)*limit,list,sheetAct);
}
}
writer.write();
}catch(Exception e){
LOGGER.error(Exception:, e.fillInStackTrace());
}
finally {
if (null != writer) {
writer.close();
}
}
return out.toByteArray();
}
findExcelData 方法:
private void findExcelData(int start,ListStudioSeriesP
您可能关注的文档
- Jacobi迭代法 Gauss-Seidel迭代法【DOC精选】.doc
- J2ME手机游戏设计案例源代码-GameEngine_TiledLayer2【DOC精选】.doc
- Jacxm9月大学英语六级考试真题及答案【DOC精选】.doc
- JADUALTENTATIFMESYUARATPERSIAPANPERSEKOLAHANSESI【DOC精选】.doc
- Java Card CAP文件分析【DOC精选】.doc
- Java Card【DOC精选】.doc
- Jason院长英语播音配音发音特训小班教学套餐【DOC精选】.docx
- Java D高级绘图【DOC精选】.doc
- Java Collections API 您不知道的 件事【DOC精选】.doc
- java excel导入数据库【DOC精选】.doc
- 云南省涧南彝族自治县2026届中考三模数学试题含解析.doc
- 重庆市巫溪中学2026届中考三模生物试题含解析.doc
- 2026届甘肃省张掖市高台县重点名校中考数学模拟精编试卷含解析.doc
- 2026届重庆一中学中考生物最后冲刺浓缩精华卷含解析.doc
- 2026届江西省萍乡市安源区中考生物模试卷含解析.doc
- 2026届山东省曲阜师范大附属实验校中考生物考前最后一卷含解析.doc
- 山西省运城市垣曲县重点中学2026届中考生物考前最后一卷含解析.doc
- 湖北省谷城县达标名校2026届中考生物押题卷含解析.doc
- 2026届河南省三门峡市义马二中中考生物考试模拟冲刺卷含解析.doc
- 树立和践行正确政绩观重点纠治十种偏差问题对照查摆清单(100条).docx
原创力文档

文档评论(0)