poi 操作excel常用方法

阅读更多
POI操作Excel常用方法

自定义颜色
HSSFCellStyle style = wb.createCellStyle();    
style.setFillForegroundColor(HSSFColor.LIME.index);    
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);    
HSSFFont font = wb.createFont();    
font.setColor(HSSFColor.RED.index);    
style.setFont(font);    
cell.setCellStyle(style);    

填充和颜色设置
HSSFCellStyle style = wb.createCellStyle();    
style.setFillBackgroundColor(HSSFColor.AQUA.index);    
style.setFillPattern(HSSFCellStyle.BIG_SPOTS);    
HSSFCell cell = row.createCell((short) 1);    
cell.setCellValue("X");    
style = wb.createCellStyle();    
style.setFillForegroundColor(HSSFColor.ORANGE.index);    
style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);    
cell.setCellStyle(style);  

复制sheet页并调整位置
Sheet newSheet = workbook.cloneSheet(newSheetIndex);
workbook.setSheetOrder(newSheet.getSheetName(), newSheetIndex+1);
workbook.setSheetName(newSheetIndex+1, "机房-"+(newSheetIndex+1));

合并单元格
sheet.addMergedRegion(new CellRangeAddress(rowspanStartNumber, rowspanEndNumber, colspanStartNumber, colspanEndNumber));


  • POI操作Excel常用方法总结.rar (31.1 KB)
  • 下载次数: 0

你可能感兴趣的:(excel,poi,excel,poi,apache,poi,apache,poi,excel)