日期:2014-05-19 浏览次数:21178 次
FileOutputStream fos = new FileOutputStream(file);
// 创建一个Excel文件对象
HSSFWorkbook wb = new HSSFWorkbook();
// 在文件对象上建立一个sheet,并命名为cliff
HSSFSheet s = wb.createSheet();
s.setColumnWidth((short) 0, (short) 6000);
s.setColumnWidth((short) 1, (short) 6000);
s.setColumnWidth((short) 2, (short) 6000);
s.setColumnWidth((short) 3, (short) 6000);
s.setColumnWidth((short) 4, (short) 6000);
// HSSFSheet s2=wb.createSheet();
wb.setSheetName(0, "统计菜单");
s.createRow(0).createCell((short) 0).setCellValue("1");
s.createRow(0).createCell((short) 1).setCellValue("2");
s.createRow(0).createCell((short) 2).setCellValue("3");
s.createRow(0).createCell((short) 3).setCellValue("4");
s.createRow(0).createCell((short) 4).setCellValue("5");
// 在sheet上输入数据
list = enterProceduralService.getEnterProcedural(enterProcedural);
for (short i = 1; i < list.size() + 1; i++) {
HSSFRow row = s.createRow(i);
row.createCell((short) 0).setCellValue(
list.get(i - 1).getMacId());
row.createCell((short) 1).setCellValue(
list.get(i - 1).getStoreName());
row.createCell((short) 2).setCellValue(
list.get(i - 1).getPadInfoId());
row.createCell((short) 3).setCellValue(
new DateUtils().cal(new Long(list.get(i - 1)
.getAdvTime()), ""));
row.createCell((short) 4).setCellValue(
new Long(list.get(i - 1).getAdvTime()) / 1000);
}
list = enterProceduralService.getAllEnterProcedural(enterProcedural);
for (int i = 1; i < (list.size()-1)/60000 +2; i++) {
HSSFSheet s2 = wb.createSheet("详情"+i);
s2.setColumnWidth((short) 0, (short) 6000);
s2.setColumnWidth((short) 1, (short) 6000);
s2.setColumnWidth((short) 2, (short) 6000);
s2.setColumnWidth((short) 3, (short) 6000);
s2.setColumnWidth((short) 4, (short) 6000);
s2.createRow(0).createCell((short) 0).setCellValue("1");
s2.createRow(0).createCell((short) 1).setCellValue("2");
s2.createRow(0).createCell((short) 2).setCellValue("3");
s2.createRow(0).createCell((short) 3).setCellValue("4");
s2.createRow(0).createCell((short) 4).setCellValue("5");
for (int j = i==1? i: (i-1)*60000+1 ; j <= (list.size()>=i*60000 ? i*60000+1 : list.size()) ; j++) {
HSSFRow row = null ;
if(i==1)
row = s2.createRow(j);
else
row = s2.createRow(j-(i-1)*60000);
row.createCell((short) 0).setCellValue(
list.get(j - 1).getMacId());
row.createCell((short) 1).setCellValue(
list.get(j - 1).getStoreName());
row.createCell((short) 2).setCellValue(
new SimpleDateFormat("yyyy-MM-dd kk:mm:ss").format(
list.get(j - 1).getCreateDate()));
row.createCell((short) 3).setCellValue(
list.get(j - 1).getApkName());
if(list.get(j - 1).getUseTime()!=null)
row.createCell((short) 4).setCellValue(
list.get(j - 1).getUseTime()/1000);
else
row.createCell((short) 4).setCellValue