Java 设置 Excel 文档属性
2020-12-22 05:30
标签:author input epo xls rop document 结果 strong rom Jar包导入: 方法二:直接通过Maven仓库安装JAR包,配置pom.xml文件的代码如下 设置内置文档属性: 设置自定义文档属性: Java 设置 Excel 文档属性 标签:author input epo xls rop document 结果 strong rom 原文地址:https://blog.51cto.com/14765544/2507723
方法一:下载Free Spire.XLS for Java包并解压缩,将lib文件夹下的Spire.Xls.jar包作为依赖项导入到Java应用程序中。import com.spire.xls.ExcelVersion;
import com.spire.xls.Workbook;
public class BuiltinProperties {
public static void main(String[] args){
//加载Excel文档
Workbook workbook = new Workbook();
workbook.loadFromFile("Input.xlsx");
//给文档设置标题、主题、作者等内置文档属性
workbook.getDocumentProperties().setTitle("设置文档属性");
workbook.getDocumentProperties().setSubject("进货单");
workbook.getDocumentProperties().setAuthor("张丽");
workbook.getDocumentProperties().setManager("王刚");
workbook.getDocumentProperties().setCompany("**公司");
workbook.getDocumentProperties().setCategory("支出");
workbook.getDocumentProperties().setKeywords("Excel文档属性");
//保存结果文档
workbook.saveToFile("BuiltinDocumentProperties.xlsx", ExcelVersion.Version2013);
}
}
import com.spire.xls.ExcelVersion;
import com.spire.xls.Workbook;
import java.util.Date;
public class CustomProperties {
public static void main(String[] args){
//加载Excel文档
Workbook workbook = new Workbook();
workbook.loadFromFile("Input.xlsx");
//给文档添加自定义文档属性
workbook.getCustomDocumentProperties().add("_MarkAsFinal", true);
workbook.getCustomDocumentProperties().add("编辑", "王晓丽");
workbook.getCustomDocumentProperties().add("联系电话", 81705109);
workbook.getCustomDocumentProperties().add("更新日期", new Date());
//保存结果文档
workbook.saveToFile("CustomDocumentProperties.xlsx", ExcelVersion.Version2013);
}
}
上一篇:python数据结构和算法
下一篇:多线程中的锁
文章标题:Java 设置 Excel 文档属性
文章链接:http://soscw.com/index.php/essay/37505.html