文档详情

java导出excel合并单元格(国外英文资料).doc

发布:2017-06-05约4.95千字共11页下载文档
文本预览下载声明
java导出excel合并单元格(国外英文资料) @ RequestMapping ( exportWells ) Public View exportWells {(HttpServletRequest request) {. View View = new AbstractExcelView () { @ Override Protected void buildExcelDocument (Map String, Object model, HSSFWorkbook workbook, it request, HttpServletResponse response) throws Exception { / / set the response mode so that the download page appears automatically when the controller is executed, rather than using excel directly The response. The reset (); Response. SetContentType ( application/VND. Ms-excel ); String filename = getFileName () + .xls ; / / notice if you remove the attachment from the following line of code; This will also enable IE to open the file automatically. Response. SetHeader. Attachment; filename = + filename; String boardId_aod = request.getparameter ( boardId_aod ); / / build Sheet HSSFSheet = workbook.createsheet ( sheet1 ); Int rowNum = 0; Int independence idx = 0; / / create titles HSSFRow header = sheet. CreateRow (rownum+ +); HSSFCellStyle cellStyle = workbook.createcellstyle (); The HSSFCellStyle centerCellStyle = workbook.createcellstyle (); CenterCellStyle. SetBorderBottom (HSSFCellStyle. CenterCellStyle. SetBorderLeft (HSSFCellStyle. CenterCellStyle. CenterCellStyle. centerCellStyle SetVerticalAlignment (HSSFCellStyle.vertical_center); / / specify the vertical center alignment of the cell CellStyle. SetWrapText (true); CellStyle. SetBorderBottom (HSSFCellStyle. CellStyle. SetBorderLeft (HSSFCellStyle. CellStyle. SetBorderRight (HSSFCellStyle. CellStyle. SetBorderTop (HSSFCellStyle. BORDER_THIN); HSSFCellStyle boldCellStyle = workbook. CreateCellStyle (); BoldCellStyle. SetWrapText (true); BoldCellStyle. BoldCellStyle. BoldCellStyle. BoldCellStyle. HSSFFont font = workbook.createfont (); SetBoldweight (hssffone.boldweight_bold); BoldCellStyle. SetFont (font); HSSFCell = header.createcell (idx + +); Cell.setcellvalue ( pure plate number ); Cell. SetCellStyle (cellStyle); Cell = header.createcell (idx + +); Cell.se
显示全部
相似文档