}
//生成一个表格
/**
* 导出Excel报表
*
* */
private void expordExcel(OutputStream os, Map<String, String> params, String fileName)
throws Exception {
if(params.get("createTimeBegin") == null && params.get("createTimeEnd")==null){
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String transTime = sdf.format(date);
String transTimeBegin = transTime + " 00:00";
String transTimeEnd = transTime + " 23:59";
params.put("createTimeBegin", transTimeBegin);
params.put("createTimeEnd", transTimeEnd);
}
List<Map<String, Object>> list = checkAccountBatchService.queryCheckAccountBatchs(params);
int row = 2; // 从第三行开始写
int col = 0; // 从第一列开始写
if (params.get("createTimeBegin") == null && params.get("createTimeEnd") == null) {
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String transTime = sdf.format(date);
String transTimeBegin = transTime + " 00:00";
String transTimeEnd = transTime + " 23:59";
params.put("createTimeBegin", transTimeBegin);
params.put("createTimeEnd", transTimeEnd);
}
Workbook wb = Workbook.getWorkbook(this.getClass().getResourceAsStream("/template/CHECK_MSG.xls"));
WritableWorkbook wwb = Workbook.createWorkbook(os, wb);
WritableSheet ws = wwb.getSheet(0);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat checkDateFormat = new SimpleDateFormat("yyyy-MM-dd");
NumberFormat nf = new NumberFormat("0.00");
WritableCellFormat numFormat = new WritableCellFormat(nf);
numFormat.setAlignment(Alignment.RIGHT);
for (int i = 0; i < list.size(); i++) {
ws.addCell(new Label(col++, row, StringUtil.filterNull(list.get(i).get("check_batch_no"))));
ws.addCell(new Label(col++, row, StringUtil.filterNull(list.get(i).get("acq_enname"))));
ws.addCell(new Label(col++, row, StringUtil.filterNull(list.get(i).get("acq_cnname"))));
ws.addCell(new jxl.write.Number(col++, row,Double.valueOf(StringUtil.getDoubleValue(list.get(i).get("acq_total_amount"))) ,numFormat));
ws.addCell(new jxl.write.Number(col++, row, Double.valueOf(StringUtil.getDoubleValue(list.get(i).get("acq_total_items")))));
ws.addCell(new jxl.write.Number(col++, row, Double.valueOf(StringUtil.getDoubleValue(list.get(i).get("acq_total_success_items")))));
ws.addCell(new jxl.write.Number(col++, row, Double.valueOf(StringUtil.getDoubleValue(list.get(i).get("acq_total_failed_items")))));
ws.addCell(new jxl.write.Number(col++, row, Double.valueOf(StringUtil.getFloatValue(list.get(i).get("total_amount"))),numFormat));
ws.addCell(new jxl.write.Number(col++, row, Double.valueOf(StringUtil.getDoubleValue(list.get(i).get("total_items")))));
ws.addCell(new jxl.write.Number(col++, row, Double.valueOf(StringUtil.getDoubleValue(list.get(i).get("total_success_items")))));
ws.addCell(new jxl.write.Number(col++, row, Double.valueOf(StringUtil.getDoubleValue(list.get(i).get("total_failed_items")))));
// ws.addCell(new jxl.write.Number(col++, row, Double.valueOf(StringUtil.filterNull(list.get(i).get("total_revoked_items")))));
ws.addCell(new Label(col++, row, StringUtil.filterNull(list.get(i).get("total_revoked_items"))));
ws.addCell(new Label(col++, row, translateCheckResult(list.get(i).get("check_result"))));
ws.addCell(new Label(col++, row, list.get(i).get("check_file_date")==null?"":checkDateFormat.format(list.get(i).get("check_file_date"))));
ws.addCell(new Label(col++, row, list.get(i).get("check_time")==null?"":dateFormat.format(list.get(i).get("check_time"))));
ws.addCell(new Label(col++, row, StringUtil.filterNull(list.get(i).get("check_file_name"))));
ws.addCell(new Label(col++, row, StringUtil.filterNull(list.get(i).get("operator"))));
ws.addCell(new Label(col++, row, list.get(i).get("create_time")==null?"":dateFormat.format(list.get(i).get("create_time"))));
row++;
col = 0;
}
wwb.write();
wwb.close();
wb.close();
os.close();
}