Excel sheet and set Tab colors to rename Java

This article will show you how to use Spire.XLS for java to rename worksheets and set tab colors for sheets in Java applications. Tools used: Free Spire.XLS for Java (free version) Getting and installing Jar files:

Method 1: Download the jar file bag through the homepage. After downloading, unzip the file and put the Spire.xls.jar file under the lib folder into the Java program. Introduce to.

Method 2: maven warehouse Introduction by installation.


import com.spire.xls.*;
import java.awt.*;

public class RenameSheetandSetTabColor {
    public static void main(String[] args) {

        //Import an Excel document
        Workbook workbook = new Workbook();
        workbook.loadFromFile("Sample.xlsx");

        //Set the new worksheet name and tab color for the first worksheet
        Worksheet worksheet = workbook.getWorksheets().get(0);
        worksheet.setName("Rename1");
        worksheet.setTabColor(Color.red);

        //Set the name of the second sheet and the color of the tab
        worksheet = workbook.getWorksheets().get(1);
        worksheet.setName("Rename2");
        worksheet.setTabColor(Color.green);

        //Set the name of the third sheet and the color of the tab
        worksheet = workbook.getWorksheets().get(2);
        worksheet.setName("Rename3");
        worksheet.setTabColor(Color.blue);

        //Save the document to a file
        workbook.saveToFile("output/Result.xlsx", ExcelVersion.Version2010);
    }
}

Effect diagram: Rename the worksheet and set tab color.png

Recommended Posts

Excel sheet and set Tab colors to rename Java
[Java] Refer to and set private variables with reflection
How to set Java constants
Java Excel Insertion and Image Extraction
Java adds and reads Excel formulas
How to get Excel sheet name list in Java (POI vs SAX)
Java implementation to create and solve mazes
[Java] How to output and write files!
How to set up and use kapt
[Java] How to set the Date time to 00:00:00
Java Excel settings background color and background image
[Introduction to Java] Variable declarations and types
Java to C and C to Java in Android Studio
How to set tabs and spaces to be visible by using the tab key to insert spaces in Java files in Eclipse
How to use ToolBar with super margin Part1 Set characters and change colors
Java (set)
[Java] Understand the difference between List and Set
Kotlin functions and lambdas to send to Java developers
How to output Excel and PDF using Excella
[Java] How to get and output standard input
Try to link Ruby and Java with Dapr
Java upload and download notes to Azure storage
[Java] (for MacOS) How to set the classpath
Add, read, and delete Excel comments in Java
How to set up and operate jEnv (Mac)
How to get and study java SE8 Gold
Java8 to start now ~ forEach and lambda expression ~
How to access Java Private methods and fields
[Java] How to use Calendar class and Date class