Search code examples
c#.netexcelepplusepplus-4

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. Now I want to remove the Related People (Author and Modified By) property of the Excel file.

How can I do this?


Solution

  • Answering my own question, this can be done by adding the Workbook.Properties.LastModefiedBy and Workbook.Properties.Author to the ExcelPackage as below:

    //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;