HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
HSSFRow row = sheet.createRow((short) 0);
HSSFCell cell = row.createCell((short) 0);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("缴费日期");
cell = row.createCell((short) 1);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("缴费号");
cell = row.createCell((short) 2);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("金额");
cell = row.createCell((short) 3);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("手续费");
cell = row.createCell((short) 4);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("缴费类型");
cell = row.createCell((short) 5);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("卡号后4位");
cell = row.createCell((short) 6);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("手机号");
cell = row.createCell((short) 7);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("流水号");
jnlsList = this.getBill2Service().getJnlsListByCriteria(
detachedCriteria);
Iterator itr = jnlsList.iterator();
WtPepJnls wtj;
short rowNum = 1;
String temp = "";
while (itr.hasNext()) {
wtj = (WtPepJnls) itr.next();
row = sheet.createRow(rowNum);
cell = row.createCell((short) 0);
temp = wtj.getPepdate();
temp = temp.substring(0, 4) + "-"
+ temp.substring(4, 6) + "-"
+ temp.substring(6, 8);
cell.setCellValue(temp);
cell = row.createCell((short) 1);
cell.setCellValue(wtj.getIntcdno());
cell = row.createCell((short) 2);
temp = "¥" + Util.FormatSum(wtj.getTranamt());
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(temp);
cell = row.createCell((short) 3);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue("¥0.00");
cell = row.createCell((short) 4);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
temp = wtj.getTrancde();
if (temp.equals("M22")) {
cell.setCellValue("水费");
} else if (temp.equals("M24")) {
cell.setCellValue("电费");
} else if (temp.equals("M26")) {
cell.setCellValue("燃气费");
} else if (temp.equals("M2H")) {
cell.setCellValue("交通罚没费");
}
cell = row.createCell((short) 5);
temp = wtj.getOutcdno();
cell.setCellValue(temp.substring(12, 16));
cell = row.createCell((short) 6);
cell.setCellValue(wtj.getTermid());
cell = row.createCell((short) 7);
cell.setCellValue(wtj.getId().getTrace());
rowNum++;
}
response.setContentType("octets/stream");
response.addHeader("Content-Disposition",
"attachment;filename=all.xls");
OutputStream fileOut = response.getOutputStream();
wb.write(fileOut);
fileOut.close();
return null;
导出数据到Excel
最新推荐文章于 2023-08-01 12:39:20 发布