When you have multiple worksheets in a workbook, you usually click on a sheet's name at the bottom of the page to view it. My question is then to know, if that "button" containing the sheet's name can take a color such as blue, green and so on.
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet();
CTColor color = CTColor.Factory.newInstance();
color.setIndexed(IndexedColors.RED.getIndex());
sheet.getCTWorksheet().getSheetPr().setTabColor(color);
I have tried above but no use
try (XSSFWorkbook wb = new XSSFWorkbook()) {
XSSFSheet sheet1 = wb.createSheet("1e");
XSSFSheet sheet = wb.createSheet("1econtent");
XSSFFont font = wb.createFont();
font.setFontHeightInPoints((short) 15);
font.setColor(IndexedColors.WHITE.getIndex());
How can I add different colours sheet and sheet1 in workbook
Please do it as follows:
sheet.setTabColor(IndexedColors.RED.getIndex());
Please check https://poi.apache.org/apidocs/dev/org/apache/poi/ss/usermodel/IndexedColors.html for more details.
EDIT:
Please do it as follows with the latest version of Apache POI:
byte[] rgb=DefaultIndexedColorMap.getDefaultRGB(IndexedColors.RED.getIndex());
sheet.setTabColor(new XSSFColor(rgb,null));
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments