Java apache POI 设置元数据

标签 java excel apache-poi

我正在使用 Apache POI 生成 Excel 报告。但 Excel 文件的属性清楚地提到我使用了 Apache POI。我想在这里提及我的软件名称

enter image description here

这是我当前的代码,我正在尝试设置自定义属性,但它不起作用。

 XSSFWorkbook xlsxSetMetadata = new XSSFWorkbook();
 xlsxSetMetadata.createSheet("Test sheet");
 POIXMLProperties props = xlsxSetMetadata.getProperties();

 POIXMLProperties.CoreProperties coreProp=props.getCoreProperties();
 coreProp.setCreator("---------------");
 coreProp.setDescription("Report");
 coreProp.setKeywords("Report ");
 coreProp.setTitle("... Report");

 POIXMLProperties.ExtendedProperties extProp=props.getExtendedProperties();
 extProp.getUnderlyingProperties().setCompany("XYX company");
 extProp.getUnderlyingProperties().setTemplate("XSSF");

 POIXMLProperties.CustomProperties custProp = props.getCustomProperties();
 custProp.addProperty("Author", "..........");
 custProp.addProperty("Program name", "MY_SOFTWARE_NAME_HERE");

 String fname = "file_name.xlsx";
 FileOutputStream out = new FileOutputStream(fname);
 xlsxSetMetadata.write(out);
 out.close();

如何将程序名称属性更改为我的程序名称?

最佳答案

使用

extProp.getUnderlyingProperties().setApplication("MY_SOFTWARE_NAME_HERE");

POIXMLProperties.ExtendedProperties下。

取自 this thread

关于Java apache POI 设置元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56429336/

相关文章:

java - 匹配简单 "id"值的正则表达式?

java - java中mongo数据库中所有集合的列表

vba - 选择工作簿时下标超出范围

excel - excel中从右到左的用户表单 - VBA

apache - 如何将Word文档导入Elastic Search

java - 使用带有 Java Servlet 的 Apache poi 找不到 PackagePropertiesMarshaller$NamespaceImpl

java - android 如何在android的Asynctask中加载sqlite数据

java - 如果我激活 `-parameters` 编译器参数,SDN 将不起作用

java - 使用 JExcel API 更改 XLS 文件的格式

java - 如何将.jar文件添加到javac编译中(Windows 10)