我正在使用 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();
如何将程序名称
属性更改为我的程序名称?
最佳答案
使用
extProp.getUnderlyingProperties().setApplication("MY_SOFTWARE_NAME_HERE");
在POIXMLProperties.ExtendedProperties
下。
取自 this thread
关于Java apache POI 设置元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56429336/