在解压缩用NPOI生成的.xlsx时,我注意到NPOI将自己设置为docProps/app.xml中的"Application“,并将”生成器“添加到docProps/custom.xml中。
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
<Application>NPOI</Application>
<AppVersion>123.456</AppVersion>
</Properties>如何在app.xml中编辑应用程序信息?
我只找到了CoreProperties,CustomProperties和ExtendedProperties,但没有什么叫"AppProperties“。
发布于 2018-10-25 13:30:37
您需要从ExtendedProperties获取基础属性,然后设置该属性的Application属性。下面的示例设置应用程序和AppVersion:
static void Main(string[] args)
{
XSSFWorkbook workbook = new XSSFWorkbook();
ISheet sheet1 = workbook.CreateSheet("Sheet1");
POIXMLProperties props = workbook.GetProperties();
//get the underlying properties (of type NPOI.OpenXmlFormats.CT_ExtendedProperties)
var underlyingProps = props.ExtendedProperties.GetUnderlyingProperties();
//now set the properties (excuse the vanity!)
underlyingProps.Application = "petelids";
underlyingProps.AppVersion = "1.0";
FileStream sw = File.Create("test.xlsx");
workbook.Write(sw);
sw.Close();
}发电机特性
更改Generator in CustomProperties (custom.xml)的示例。
CustomProperties customProperties = properies.CustomProperties;
customProperties.AddProperty("Generator", "petelids");
customProperties.AddProperty("Generator Version", "1.0");https://stackoverflow.com/questions/52988023
复制相似问题