POI TABEL设计
/*创建合并单元格 begin*/
/*基本情况set*/
CellRangeAddress region = new CellRangeAddress(1, 1, 0, 11);
sheet.addMergedRegion(region);
/*行政案件与刑事案件需分别处理*/
if (Constans.CASE_TYPE.ADMIN.key.equals(caseType)){
/*行政处置情况set*/
CellRangeAddress region12 = new CellRangeAddress(1, 1, 12, 16);
sheet.addMergedRegion(region12);
/*备注set*/
CellRangeAddress region17 = new CellRangeAddress(1, 3, 17, 17);
sheet.addMergedRegion(region17);
/*填报时间set*/
CellRangeAddress region18 = new CellRangeAddress(1, 3, 18, 18);
sheet.addMergedRegion(region18);
/*审核set*/
CellRangeAddress region19 = new CellRangeAddress(1, 3, 19, 19);
sheet.addMergedRegion(region19);
for (int i =0;i<14;i++){
CellRangeAddress region5 = new CellRangeAddress(2, 3, i, i);
sheet.addMergedRegion(region5);
}
CellRangeAddress region6 = new CellRangeAddress(2, 2, 14, 15);
CellRangeAddress region7 = new CellRangeAddress(2, 3, 16, 16);
sheet.addMergedRegion(region6);
sheet.addMergedRegion(region7);
/*在sheet里增加合并单元格*/
/*填充第二行数据*/
XSSFRow rowTitle1 =sheet.createRow(1);
XSSFCell cellTitle= rowTitle1.createCell(0);
cellTitle.setCellStyle(headerStyle);
cellTitle.setCellValue("基本情况");
XSSFCell cellTitle12 = rowTitle1.createCell(12);
cellTitle12.setCellStyle(headerStyle);
cellTitle12.setCellValue("行政处置情况");
XSSFCell cellTitle17 = rowTitle1.createCell(17);
cellTitle17.setCellStyle(headerStyle);
cellTitle17.setCellValue(BizHelper.ADMIN_HEDER_NAMES[17]);
XSSFCell cellTitle18 = rowTitle1.createCell(18);
cellTitle18.setCellStyle(headerStyle);
cellTitle18.setCellValue(BizHelper.ADMIN_HEDER_NAMES[18]);
XSSFCell cellTitle19 = rowTitle1.createCell(19);
cellTitle19.setCellStyle(headerStyle);
cellTitle19.setCellValue(BizHelper.ADMIN_HEDER_NAMES[19]);
/*填充第三行数据*/
XSSFRow rowTitle2 =sheet.createRow(2);
for(int i=0;i<14;i++){
XSSFCell cellTitle21 = rowTitle2.createCell(i);
cellTitle21.setCellStyle(headerStyle);
cellTitle21.setCellValue(BizHelper.ADMIN_HEDER_NAMES[i]);
}
XSSFCell cellTitle214 = rowTitle2.createCell(14);
cellTitle214.setCellStyle(headerStyle);
cellTitle214.setCellValue("行政认定");
XSSFCell cellTitle216 = rowTitle2.createCell(16);
cellTitle216.setCellStyle(headerStyle);
cellTitle216.setCellValue(BizHelper.ADMIN_HEDER_NAMES[16]);
/*第三行填充数据*/
XSSFRow rowTitle3 =sheet.createRow(3);
XSSFCell cellTitle314 = rowTitle3.createCell(14);
cellTitle314.setCellStyle(headerStyle);
cellTitle314.setCellValue(BizHelper.ADMIN_HEDER_NAMES[14]);
XSSFCell cellTitle315 = rowTitle3.createCell(15);
cellTitle315.setCellStyle(headerStyle);
cellTitle315.setCellValue(BizHelper.ADMIN_HEDER_NAMES[15]);
}else if(Constans.CASE_TYPE.CRIMINAL.key.equals(caseType)){
/*行政处置情况set*/
CellRangeAddress region12 = new CellRangeAddress(1, 1, 12, 12);
sheet.addMergedRegion(region12);
/*备注set*/
CellRangeAddress region13 = new CellRangeAddress(1, 2, 13, 13);
sheet.addMergedRegion(region13);
/*填报时间set*/
CellRangeAddress region14 = new CellRangeAddress(1, 2, 14, 14);
sheet.addMergedRegion(region14);
/*审核set*/
CellRangeAddress region15 = new CellRangeAddress(1, 2, 15, 15);
sheet.addMergedRegion(region15);
/*在sheet里增加合并单元格*/
/*填充第二行数据*/
XSSFRow rowTitle1 =sheet.createRow(1);
XSSFCell cellTitle= rowTitle1.createCell(0);
cellTitle.setCellStyle(headerStyle);
cellTitle.setCellValue("基本情况");
XSSFCell cellTitle12 = rowTitle1.createCell(12);
cellTitle12.setCellStyle(headerStyle);
cellTitle12.setCellValue("行政处置情况");
XSSFCell cellTitle13 = rowTitle1.createCell(13);
cellTitle13.setCellStyle(headerStyle);
cellTitle13.setCellValue(BizHelper.CRIMINAL_HEDER_NAMES[13]);
XSSFCell cellTitle14 = rowTitle1.createCell(14);
cellTitle14.setCellStyle(headerStyle);
cellTitle14.setCellValue(BizHelper.CRIMINAL_HEDER_NAMES[14]);
XSSFCell cellTitle15 = rowTitle1.createCell(15);
cellTitle15.setCellStyle(headerStyle);
cellTitle15.setCellValue(BizHelper.CRIMINAL_HEDER_NAMES[15]);
XSSFRow rowTitle2 =sheet.createRow(2);
for(int i=0;i<14;i++){
XSSFCell cellTitle21 = rowTitle2.createCell(i);
cellTitle21.setCellStyle(headerStyle);
cellTitle21.setCellValue(BizHelper.CRIMINAL_HEDER_NAMES[i]);
}
}
效果如下