Java apache POI 设置元数据

mri*_*rid 2 java excel apache-poi

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

在此处输入图片说明

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

 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();
Run Code Online (Sandbox Code Playgroud)

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

Xtr*_*mer 5

extProp.getUnderlyingProperties().setApplication("MY_SOFTWARE_NAME_HERE");
Run Code Online (Sandbox Code Playgroud)

POIXMLProperties.ExtendedProperties

取自这个线程