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.
Get started making PDFs with NuGet now:
Install IronXL with NuGet Package Manager
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");Deploy to test on your live environment
Minimal Workflow (5 steps)
- Download the C# library to edit workbook metadata
- Load an existing spreadsheet or create a brand new one
- Access and modify the metadata information using the `Metadata` property
- View and modify the spreadsheet data
- Export the spreadsheet with the edited metadata properties
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.csusing 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")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.comWhat 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:

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?
| Property | Description | Operations | Common Use Cases |
|---|---|---|---|
Author | Document creator name | Set, Modify, Retrieve | Tracking document ownership, compliance |
Comments | Additional notes about the document | Set, Modify, Retrieve | Version notes, processing instructions |
LastPrinted | Date/time of last print operation | Set, Modify, Retrieve | Print history tracking, audit trails |
Keywords | Searchable keywords | Set, Modify, Retrieve | Document categorization, search optimization |
Category | Document category classification | Set, Modify, Retrieve | File organization, departmental sorting |
Created | Document creation date | Set, Modify, Retrieve | Document age tracking, archival decisions |
ModifiedDate | Last modification date | Set, Modify, Retrieve | Change tracking, version control |
Subject | Document subject description | Set, Modify, Retrieve | Content summarization, quick identification |
Title | Document title | Set, Modify, Retrieve | Document identification, reporting |
Which Properties Are Read-Only?
| Property | Description | Typical Values |
|---|---|---|
ApplicationName | Name of the application that created the file | "Microsoft Excel", "IronXL" |
CustomProperties | User-defined custom properties | Varies by document |
Company | Company name associated with the document | Organization name from system |
Manager | Manager name from document properties | Retrieved from original file |
Template | Template used to create the document | Template 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.






