欢迎来到天天文库
浏览记录
ID:51690431
大小:166.00 KB
页数:6页
时间:2020-03-15
《java生成excel模板导出.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、java生成excel模板导出getTimeStr方法:publicstaticStringgetTimeStr(Datedate,Stringformat){ SimpleDateFormatsimpleDateFormat=newSimpleDateFormat(format); returnsimpleDateFormat.format(date); } createExcelModel方法全部代码:publicstaticHSSFWorkbookcreateExcelModel()throwsException{ HSSFWorkbookwb=newHSS
2、FWorkbook();//创建工作薄 HSSFSheetsheet=wb.createSheet("任务模板");//新建工作表 HSSFRowrow=sheet.createRow((short)0);//创建行 row.setHeightInPoints((short)20);//设置excel单元格高度 HSSFRichTextStringtext=null; HSSFFontfont=wb.createFont(); font.setColor(HSSFFont.COLOR_RED); font.setBoldweight(HSSFFont.BO
3、LDWEIGHT_BOLD); HSSFCellStylestyle=wb.createCellStyle(); style.setFont(font); for(inti=0;i<21;i++){//创建列 HSSFCellcell=row.createCell(i);//创建单元格 switch(i){ case0: if(i==0){ text=newHSSFRichTextString("客户编号"); cell.setCellValue(text); cell.setCellStyle(style);
4、 cell.setCellType(HSSFCell.CELL_TYPE_STRING); } case1: if(i==1){ text=newHSSFRichTextString("客户姓名"); cell.setCellValue(text); cell.setCellStyle(style); cell.setCellType(HSSFCell.CELL_TYPE_STRING); } case2: if(i==2){ text=newHSSFRichTextS
5、tring("英文名称"); cell.setCellValue(text); cell.setCellType(HSSFCell.CELL_TYPE_STRING); } case3: if(i==3){ text=newHSSFRichTextString("英文简称"); cell.setCellValue(text); cell.setCellType(HSSFCell.CELL_TYPE_STRING); } case4: if(i==4){ text=ne
6、wHSSFRichTextString("客户级别"); cell.setCellValue(text); cell.setCellStyle(style);// cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC); } case5: if(i==5){ text=newHSSFRichTextString("证件类别"); cell.setCellValue(text); cell.setCellStyle(style);// cell.s
7、etCellType(HSSFCell.CELL_TYPE_NUMERIC); } case6: if(i==6){ text=newHSSFRichTextString("证件号码"); cell.setCellValue(text); cell.setCellStyle(style);// cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC); } case7: if(i==7){ text=newHSSF
此文档下载收益归作者所有