简体   繁体   English

如何使用 C# 中的 EPPlus 删除 Excel 文件的相关人员(作者和修改者)属性

[英]How to remove the Related People (Author and Modified By) property of Excel file using EPPlus in C#

I am using the EPPlus to create an excel file.我正在使用 EPPlus 创建 excel 文件。 Now I want to remove the Related People (Author and Modified By) property of the Excel file.现在我想删除 Excel 文件的相关人员(作者和修改者)属性。

How can I do this?我怎样才能做到这一点?

Answering my own question, this can be done by adding the Workbook.Properties.LastModefiedBy and Workbook.Properties.Author to the ExcelPackage as below:回答我自己的问题,这可以通过将Workbook.Properties.LastModefiedByWorkbook.Properties.Author添加到ExcelPackage来完成,如下所示:

//Get file info of temp excel file
FileInfo newFile = new FileInfo(@"your-docx-file-path");
//Create ExcelPackage for excel file
ExcelPackage pck = new ExcelPackage(newFile);

pck.Workbook.Properties.LastModifiedBy = string.Empty;
pck.Workbook.Properties.Author = string.Empty;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM