How can add different colour for each worksheet in excel using Apache POI

shivani yadav

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
Arvind Kumar Avinash

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.

edited at
0

Comments

0 comments
Login to comment

Related

How to add header column in excel using Java Apache POI?

Remove all borders on a specific excel worksheet using Apache POI

Apache POI: change page format for Excel worksheet

How can I produce a scatterplot using ggplot in R where each column is a different colour?

How to add superscript text using Apache POI

How to use Apache POI Workbook to sprarate different data in different excel?

How to plot each bar with different colour using MATLAB code?

How to add Data validation to entire column of an excel sheet using apache poi in java?

How to add new sheets to existing excel workbook using apache POI and PrimeFaces

How to add columns to an existing large excel file using SXSSF Apache POI?

how to change the tab color of a worksheet with Apache Poi

How to select and bold the whole worksheet with Apache POI

How can you check if an excel cell is locked using Apache POI API?

Using Excel templates with Apache POI

How can I get every bar in different colour using Highchart?

Why is my Apache POI code not reading excel worksheet?

how can I styling cells in Excel by Apache POI?

How to insert a table in ms excel using apache java poi

Using Apache POI how to read a specific excel column

How to apply background color for the rows in excel sheet using Apache POI?

how to write metadata into Excel workbooks using Apache POI in Java

How to remove warning in Excel using apache poi in JAVA?

How to search an Excel sheet for a specific date using Apache POI?

How to Deal with empty or blank cell in excel file using apache poi

How to Convert PDF to Excel in java using Apache Poi

How to read an MS excel file using Apache POI?

How to write in cell in excel using apache POI in JAVA?

How to get value from excel using apache poi

How to get currency code from Excel using Apache POI?

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  3. 3

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  4. 4

    pump.io port in URL

  5. 5

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    Do Idle Snowflake Connections Use Cloud Services Credits?

  9. 9

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  10. 10

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  11. 11

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  12. 12

    Generate random UUIDv4 with Elm

  13. 13

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  14. 14

    Is it possible to Redo commits removed by GitHub Desktop's Undo on a Mac?

  15. 15

    flutter: dropdown item programmatically unselect problem

  16. 16

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  17. 17

    EXCEL: Find sum of values in one column with criteria from other column

  18. 18

    Pandas - check if dataframe has negative value in any column

  19. 19

    How to use merge windows unallocated space into Ubuntu using GParted?

  20. 20

    Make a B+ Tree concurrent thread safe

  21. 21

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

HotTag

Archive