How to Edit Workbook Metadata in C#

How to Edit Excel Workbook Metadata in C#

Edit Excel metadata in C# using IronXL’s Metadata property to programmatically set author, title, keywords, and other document properties without Microsoft Interop, enabling automated spreadsheet organization and searchability.

Metadata for an Excel spreadsheet includes information about the title, author, subject, keywords, creation date, modification date, and other relevant details. Metadata provides context and helps in organizing and categorizing spreadsheets. It simplifies file search and management, especially when working with multiple spreadsheet files. Whether you’re creating new spreadsheets or loading existing workbooks, IronXL makes metadata management seamless.

Quickstart: Edit workbook metadata in one easy step

Set, modify, and save properties like Title, Author, or Keywords using IronXL’s Metadata interface. No need for Interop—get started instantly with just a few lines of clean, intuitive C# code.

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronXL with NuGet Package Manager

    PM > Install-Package IronXL.Excel

  2. Copy and run this code snippet.

    IronXL.WorkBook.Load("input.xlsx").Metadata.Title = "Financial Summary";
    // Then save your update to a new file
    IronXL.WorkBook.Load("input.xlsx").SaveAs("output.xlsx");
  3. Deploy to test on your live environment

    Start using IronXL in your project today with a free trial
    arrow pointer

How Do I Edit Workbook Metadata Properties?

To edit the author name of a spreadsheet file, set the Author property with the desired string of data. For example, workBook.Metadata.Author = "Your Name". The metadata information available in the Metadata property of WorkBook class can be accessed and retrieved. This approach works seamlessly with various spreadsheet file types including XLSX, XLS, and CSV formats.

Which Properties Can I Modify Programmatically?

:path=/static-assets/excel/content-code-examples/how-to/edit-workbook-metadata.cs
using IronXL;
using System;

WorkBook workBook = WorkBook.Load("sample.xlsx");

// Set author
workBook.Metadata.Author = "Your Name";
// Set comments
workBook.Metadata.Comments = "Monthly report";
// Set title
workBook.Metadata.Title = "July";
// Set keywords
workBook.Metadata.Keywords = "Report";

// Read the creation date of the excel file
DateTime? creationDate = workBook.Metadata.Created;

// Read the last printed date of the excel file
DateTime? printDate = workBook.Metadata.LastPrinted;

workBook.SaveAs("editedMetadata.xlsx");
Imports IronXL
Imports System

Private workBook As WorkBook = WorkBook.Load("sample.xlsx")

' Set author
workBook.Metadata.Author = "Your Name"
' Set comments
workBook.Metadata.Comments = "Monthly report"
' Set title
workBook.Metadata.Title = "July"
' Set keywords
workBook.Metadata.Keywords = "Report"

' Read the creation date of the excel file
Dim creationDate? As DateTime = workBook.Metadata.Created

' Read the last printed date of the excel file
Dim printDate? As DateTime = workBook.Metadata.LastPrinted

workBook.SaveAs("editedMetadata.xlsx")
$vbLabelText   $csharpLabel

For more complex scenarios, you can combine metadata editing with other Excel operations. Here’s a comprehensive example that demonstrates batch processing of multiple Excel files:

using IronXL;
using System;
using System.IO;

public class BatchMetadataProcessor
{
    public static void ProcessFinancialReports(string folderPath)
    {
        // Get all Excel files in the directory
        string[] excelFiles = Directory.GetFiles(folderPath, "*.xlsx");

        foreach (string filePath in excelFiles)
        {
            // Load the workbook
            WorkBook workBook = WorkBook.Load(filePath);

            // Update metadata based on file content
            string fileName = Path.GetFileNameWithoutExtension(filePath);

            // Set consistent metadata across all reports
            workBook.Metadata.Author = "Finance Department";
            workBook.Metadata.Company = "Your Company Name";
            workBook.Metadata.Category = "Financial Reports";

            // Set dynamic metadata based on filename
            if (fileName.Contains("Q1"))
            {
                workBook.Metadata.Title = "Q1 Financial Report";
                workBook.Metadata.Keywords = "Q1, Finance, Quarterly";
            }
            else if (fileName.Contains("Q2"))
            {
                workBook.Metadata.Title = "Q2 Financial Report";
                workBook.Metadata.Keywords = "Q2, Finance, Quarterly";
            }

            // Add timestamp to comments
            workBook.Metadata.Comments = $"Processed on {DateTime.Now:yyyy-MM-dd HH:mm}";

            // Set the subject based on worksheet content
            WorkSheet sheet = workBook.DefaultWorkSheet;
            workBook.Metadata.Subject = $"Report containing {sheet.RowCount} data rows";

            // Save with updated metadata
            string outputPath = Path.Combine(folderPath, "processed", fileName + "_updated.xlsx");
            workBook.SaveAs(outputPath);
        }
    }
}
using IronXL;
using System;
using System.IO;

public class BatchMetadataProcessor
{
    public static void ProcessFinancialReports(string folderPath)
    {
        // Get all Excel files in the directory
        string[] excelFiles = Directory.GetFiles(folderPath, "*.xlsx");

        foreach (string filePath in excelFiles)
        {
            // Load the workbook
            WorkBook workBook = WorkBook.Load(filePath);

            // Update metadata based on file content
            string fileName = Path.GetFileNameWithoutExtension(filePath);

            // Set consistent metadata across all reports
            workBook.Metadata.Author = "Finance Department";
            workBook.Metadata.Company = "Your Company Name";
            workBook.Metadata.Category = "Financial Reports";

            // Set dynamic metadata based on filename
            if (fileName.Contains("Q1"))
            {
                workBook.Metadata.Title = "Q1 Financial Report";
                workBook.Metadata.Keywords = "Q1, Finance, Quarterly";
            }
            else if (fileName.Contains("Q2"))
            {
                workBook.Metadata.Title = "Q2 Financial Report";
                workBook.Metadata.Keywords = "Q2, Finance, Quarterly";
            }

            // Add timestamp to comments
            workBook.Metadata.Comments = $"Processed on {DateTime.Now:yyyy-MM-dd HH:mm}";

            // Set the subject based on worksheet content
            WorkSheet sheet = workBook.DefaultWorkSheet;
            workBook.Metadata.Subject = $"Report containing {sheet.RowCount} data rows";

            // Save with updated metadata
            string outputPath = Path.Combine(folderPath, "processed", fileName + "_updated.xlsx");
            workBook.SaveAs(outputPath);
        }
    }
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

What Happens to Existing Metadata When I Save?

When you save or export Excel files using IronXL, any metadata properties you haven’t explicitly modified retain their original values. Only the properties you’ve changed will be updated in the saved file. This selective update approach ensures that valuable existing metadata isn’t accidentally lost during processing. The image below shows how metadata appears in Excel’s document properties panel after being edited with IronXL:

Excel document properties panel showing edited metadata fields including Author, Title, Subject, and Keywords after modification with IronXL

If you need to clear existing metadata before setting new values, simply assign empty strings or null values to the properties you want to reset. This is particularly useful when preparing documents for external distribution where you want to remove internal company information.


What Metadata Fields Are Available in IronXL?

Not all metadata properties can be edited. Some properties can only be retrieved. Understanding which properties support different operations is crucial for effective metadata management. When working with password-protected workbooks, metadata can still be accessed and modified after the workbook is successfully decrypted.

Which Properties Support Read and Write Operations?

PropertyDescriptionOperationsCommon Use Cases
AuthorDocument creator nameSet, Modify, RetrieveTracking document ownership, compliance
CommentsAdditional notes about the documentSet, Modify, RetrieveVersion notes, processing instructions
LastPrintedDate/time of last print operationSet, Modify, RetrievePrint history tracking, audit trails
KeywordsSearchable keywordsSet, Modify, RetrieveDocument categorization, search optimization
CategoryDocument category classificationSet, Modify, RetrieveFile organization, departmental sorting
CreatedDocument creation dateSet, Modify, RetrieveDocument age tracking, archival decisions
ModifiedDateLast modification dateSet, Modify, RetrieveChange tracking, version control
SubjectDocument subject descriptionSet, Modify, RetrieveContent summarization, quick identification
TitleDocument titleSet, Modify, RetrieveDocument identification, reporting

Which Properties Are Read-Only?

PropertyDescriptionTypical Values
ApplicationNameName of the application that created the file"Microsoft Excel", "IronXL"
CustomPropertiesUser-defined custom propertiesVaries by document
CompanyCompany name associated with the documentOrganization name from system
ManagerManager name from document propertiesRetrieved from original file
TemplateTemplate used to create the documentTemplate filename or "Normal"

For advanced metadata operations and complete API documentation, refer to the IronXL API Reference. If you encounter any issues with metadata handling, consult our troubleshooting guides or explore licensing options for production deployments.

Frequently Asked Questions

How can I edit Excel metadata programmatically in C#?

IronXL provides a simple Metadata property on the WorkBook class that allows you to programmatically edit Excel metadata. You can easily set properties like Title, Author, Subject, and Keywords without needing Microsoft Interop. Simply load your workbook and access workBook.Metadata to modify any metadata property.

What metadata properties can I modify in an Excel file?

With IronXL, you can modify various metadata properties including Author, Title, Subject, Keywords, Category, Comments, Status, Manager, and Company. The library also provides read-only access to creation and modification dates, allowing comprehensive metadata management for your spreadsheets.

Do I need Microsoft Office installed to edit Excel metadata?

No, IronXL doesn't require Microsoft Office or Interop to be installed. It's a standalone C# library that can read, write, and modify Excel files and their metadata independently, making it ideal for server environments or systems without Office installations.

Can I batch process metadata for multiple Excel files?

Yes, IronXL supports batch processing of Excel files. You can iterate through multiple spreadsheets in a directory, load each one using WorkBook.Load(), modify their metadata properties, and save them back. This is particularly useful for organizing large collections of spreadsheet files.

Which Excel file formats support metadata editing?

IronXL's metadata editing capabilities work seamlessly with various spreadsheet file formats including XLSX, XLS, and CSV files. The library handles the format-specific details internally, allowing you to use the same Metadata property interface regardless of the file type.

How do I save the metadata changes after editing?

After modifying metadata properties using IronXL, simply call the Save() method to update the existing file or SaveAs() to create a new file with the updated metadata. The library automatically persists all metadata changes along with any spreadsheet data modifications.

Chaknith Bin
Software Engineer
Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience.
Ready to Get Started?
Nuget Downloads 1,765,830 | Version: 2025.12 just released