Java sets Excel document properties

Excel document properties are descriptive information and include items such as author, title, subject, keywords, and categories. Setting properties for Excel documents allows users to manage Excel documents more conveniently and quickly. This article will show you how to use Free Spire.XLS for Java to set built-in and custom document properties in an Excel document.

** Environment configuration: ** ** Method 1: ** Free Spire.XLS for Java Download the package, unzip it, and create the lib folder. Import the Spire.Xls.jar package as a dependency into your Java application.

** Method 2: ** You can also install the JAR package directly from the Maven repository The code that makes up the pom.xml file is:

<repositories>
        <repository>
            <id>com.e-iceblue</id>
            <name>e-iceblue</name>
            <url>http://repo.e-iceblue.com/nexus/content/groups/public/</url>
        </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>e-iceblue</groupId>
        <artifactId>spire.xls.free</artifactId>
        <version>2.2.0</version>
    </dependency>
</dependencies>

** Set built-in document properties: **

import com.spire.xls.ExcelVersion;
import com.spire.xls.Workbook;

public class BuiltinProperties {
    public static void main(String[] args){
        //Import an Excel document
        Workbook workbook = new Workbook();
        workbook.loadFromFile("test.xlsx");

        //Set document title, subject, author, and other built-in document attributes
        workbook.getDocumentProperties().setTitle("Set document properties");
        workbook.getDocumentProperties().setSubject("purchase order");
        workbook.getDocumentProperties().setAuthor("AAA");
        workbook.getDocumentProperties().setManager("BBB");
        workbook.getDocumentProperties().setCompany("Company C");
        workbook.getDocumentProperties().setCategory("Spending");
        workbook.getDocumentProperties().setKeywords("Excel document properties");

        //Save result file
        workbook.saveToFile("BuiltinDocumentProperties.xlsx", ExcelVersion.Version2013);
    }
}

in.jpg

** Set custom document properties: **

import com.spire.xls.ExcelVersion;
import com.spire.xls.Workbook;

import java.util.Date;

public class CustomProperties {
    public static void main(String[] args){
        //Import an Excel document
        Workbook workbook = new Workbook();
        workbook.loadFromFile("Input.xlsx");

        //Add custom document properties to your document
        workbook.getCustomDocumentProperties().add("_MarkAsFinal", true);
        workbook.getCustomDocumentProperties().add("To edit", "AAA");
        workbook.getCustomDocumentProperties().add("Contact number", 81705109);
        workbook.getCustomDocumentProperties().add("date", new Date());

        //Save result file
        workbook.saveToFile("CustomDocumentProperties.xlsx", ExcelVersion.Version2013);
    }
}

cu.png

Recommended Posts

Java sets Excel document properties
Java creates an Excel document
Java compressed PDF document
Save Java PDF in Excel
Let's operate Excel with Java! !!
Importing Excel data in Java 2
Java turns Excel into PDF
Import Excel data in Java
Java sets different background colors for adjacent rows in Excel
Java addition excel data validation
Importing Excel data in Java 3
This is the Excel output in Java! "JXLS" official document translation
Java Excel Insertion and Image Extraction
Read Java properties file in C #
Add watermark to Java to PDF document
EXCEL file update sample with JAVA
[Java] Add WordArt to Word document
Java adds and reads Excel formulas