Excel로 데이터 내보내기

3587 단어 Excel교통.

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;

좋은 웹페이지 즐겨찾기