http://jakarta.apache.org/poi/hssf/quick-guide.html
http://jakarta.apache.org/poi/hssf/quick-guide.html 问题点数:1、回复次数:1Top
1 楼qq200577()回复于 2005-09-30 17:58:52 得分 1
// response.setContentType(CONTENT_TYPE);
// InputStream in = this.getClass().getResourceAsStream(
// "/com/paic/cm/template/Printparticularaccountlist.xls");
//
// response.setHeader("Content-Disposition", "attachment;filename="
// + new String("帐户明细表.xls".getBytes(), "ISO8859_1"));
List lableList =(List) request.getAttribute("lablelist");
List valueList =(List) request.getAttribute("valuelist");
wb = new HSSFWorkbook();
sheet = wb.createSheet("accountparticularInfo");
row = sheet.createRow(2);
font = wb.createFont();
HSSFRow row1 = null ;
cellStyle = wb.createCellStyle();
cellStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
int i = -1 ;//数据标记
int j = 2 ;//填充数据的行数
Iterator it1 =lableList.iterator();
Iterator it2 =valueList.iterator();
while((it1.hasNext()) && (it2.hasNext())){
i++;
j++;
TableToLableVO tableToLableVO = (TableToLableVO)it1.next();
AccountVO accountVO =(AccountVO)it2.next();
cell = row.createCell( (short) i);
sheet.setColumnWidth((short)i,(short) (( 30 * 8 ) / ( (double) 1 / 20 )));
font.setFontName("Arial");
font.setBoldweight((short)1230);
font.setFontHeightInPoints((short)12);
cellStyle.setFont(font);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellStyle(cellStyle);
cell.setCellValue(tableToLableVO.getDisplayName());
row1 = sheet.createRow(j);
String lable = tableToLableVO.getColname();
if(lable.equalsIgnoreCase("ACCOUNT")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getAccount());
}
if(lable.equalsIgnoreCase("REALACCOUNT")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getRealaccount());
}
if(lable.equalsIgnoreCase("CHANGEDATE")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy h:mm"));
cell.setCellValue(accountVO.getChangedate());
}
if(lable.equalsIgnoreCase("CHANGEUSER")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getChangeuser());
}
if(lable.equalsIgnoreCase("APPROVENO")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getApproveno());
}
if(lable.equalsIgnoreCase("ACCESSORIES")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getAccessories());
}
if(lable.equalsIgnoreCase("CREATEDATE")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy h:mm"));
cell.setCellValue(accountVO.getCreatedate());
}
if(lable.equalsIgnoreCase("CANCELDATE")){
cell = row1.createCell( (short)i);
cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy h:mm"));
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getCanceldate());
}
if(lable.equalsIgnoreCase("BRANCHGRADE")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getBranchgrade());
}
if(lable.equalsIgnoreCase("ISAUTO")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getIsauto());
}
if(lable.equalsIgnoreCase("BANKNAME")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getBankname());
}
if(lable.equalsIgnoreCase("PAYADDR")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getPayaddr());
}
if(lable.equalsIgnoreCase("BANKSIGN")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getBanksign());
}
if(lable.equalsIgnoreCase("TNO")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getTno());
}
if(lable.equalsIgnoreCase("ACCTSIGN")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getAcctsign());
}
if(lable.equalsIgnoreCase("CURRENCY")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getCurrency());
}
if(lable.equalsIgnoreCase("BANKCODE")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getBankcode());
}
if(lable.equalsIgnoreCase("BANKID")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getBranchid());
}
if(lable.equalsIgnoreCase("BRANCHID")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getBranchid());
}
if(lable.equalsIgnoreCase("PAYOR")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getPayor());
}
if(lable.equalsIgnoreCase("PAYTYPE")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getPaytype());
}
if(lable.equalsIgnoreCase("PROPERTY")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getProperty());
}
if(lable.equalsIgnoreCase("USESTATUS")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getUsestatus());
}
if(lable.equalsIgnoreCase("COMM")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getComm());
}
if(lable.equalsIgnoreCase("MULTIRULE")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getMultirule());
}
if(lable.equalsIgnoreCase("DATERULE")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getDaterule());
}
if(lable.equalsIgnoreCase("OPINION")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getOpinion());
}
if(lable.equalsIgnoreCase("ISDIRECT")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getIsdirect());
}
if(lable.equalsIgnoreCase("PROVCODE")){
cell = row1.createCell( (short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(accountVO.getProvcode());
}
}
FileOutputStream fileOut = new FileOutputStream("d:/帐号明细表.xls");
wb.write(fileOut);
fileOut.close();
Top




