首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何用NPOI改变app.xml (XSSF)中的应用?

如何用NPOI改变app.xml (XSSF)中的应用?
EN

Stack Overflow用户
提问于 2018-10-25 11:18:51
回答 1查看 342关注 0票数 2

在解压缩用NPOI生成的.xlsx时,我注意到NPOI将自己设置为docProps/app.xml中的"Application“,并将”生成器“添加到docProps/custom.xml中。

代码语言:javascript
复制
<?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中编辑应用程序信息?

我只找到了CorePropertiesCustomPropertiesExtendedProperties,但没有什么叫"AppProperties“。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-10-25 13:30:37

您需要从ExtendedProperties获取基础属性,然后设置该属性的Application属性。下面的示例设置应用程序和AppVersion:

代码语言:javascript
复制
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)的示例。

代码语言:javascript
复制
CustomProperties customProperties = properies.CustomProperties;
customProperties.AddProperty("Generator", "petelids");
customProperties.AddProperty("Generator Version", "1.0");
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52988023

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档