POI设置Excel行或单元格的背景色


POI:set background color for a row or a cell.

use setFillForegroundColor and setFillPattern at the same.

Note that not setFillBackgroundColor.

XSSFCellStyle newstyle = wb.createCellStyle();
newstyle.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
newstyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);

 

POI:set the last sheet selected, use setActiveSheet method.

XSSFWorkbook wb = new XSSFWorkbook(inputStream);
...
wb.setActiveSheet(newExcelCreat.getNumberOfSheets() - 1);

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM