导出数据到excel时怎么分工作表
请教各位大侠,我需要将查询出来的数据生成excel表格的格式保存,数据量少的情况下没有任何问题,但是一旦数据量大于65536行时,其他的数据就写不进去了 ,如何控制在写了6万跳数据时,让它自动换到一个空的工作表中~~~~~~····~~~
------解决方案--------------------int sheetNum = -1;
WritableSheet sheet = null;
int j=1;
for(int i=1; i<=list.size(); i++){
if((int)i/65535!=sheetNum){
sheetNum = (int)i/65535;
sheet = createSheet(workbook, "sheetname_"+(sheetNum+1), sheetNum);
j=1;
}
Datas datas = list.get(i-1);
sheet.addCell(new Label( 0, j, datas.getColumnA()));
sheet.addCell(new Label( 1, j, datas.getColumnB()));
j++;
}
private WritableSheet createSheet(WritableWorkbook workbook, String name, int num)throws Exception{
//创建新sheet
WritableSheet sheet = workbook.createSheet(name, num);
//写表头
sheet.addCell(new Label( 0, 0, "columnA"));
sheet.addCell(new Label( 1,0,"columnB"));
return sheet;
}