How to Edit Workbook Metadata
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.
The IronXL library offers the capability to edit workbook metadata without the need for Office Interop.
How to Edit Workbook Metadata
- 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
Get started with IronXL
Start using IronXL in your project today with a free trial.
Edit Workbook Metadata Example
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.
:path=/static-assets/excel/content-code-examples/how-to/edit-workbook-metadata.cs
using IronXL;
using System;
// Load the Excel workbook from a file
WorkBook workBook = WorkBook.Load("sample.xlsx");
// Check if the workbook is loaded successfully
if (workBook == null)
{
Console.WriteLine("Failed to load the workbook.");
return;
}
// Set metadata properties for the workbook
workBook.Metadata.Author = "Your Name"; // Specify the author of the document
workBook.Metadata.Comments = "Monthly report"; // Add comments to describe the document
workBook.Metadata.Title = "July"; // Set the title of the document
workBook.Metadata.Keywords = "Report"; // Add keywords for better searching
// Read the creation date of the Excel file
DateTime? creationDate = workBook.Metadata.Created;
// Optional: Output the creation date to the console for verification
if (creationDate.HasValue)
{
Console.WriteLine($"File creation date: {creationDate.Value}");
}
else
{
Console.WriteLine("Creation date is not available.");
}
// Read the last printed date of the Excel file
DateTime? printDate = workBook.Metadata.LastPrinted;
// Optional: Output the last printed date to the console for verification
if (printDate.HasValue)
{
Console.WriteLine($"File last printed date: {printDate.Value}");
}
else
{
Console.WriteLine("Last printed date is not available.");
}
// Save the workbook with the new metadata
try
{
workBook.SaveAs("editedMetadata.xlsx");
Console.WriteLine("Workbook saved successfully with updated metadata.");
}
catch (Exception ex)
{
Console.WriteLine($"Failed to save the workbook. Error: {ex.Message}");
}
Imports IronXL
Imports System
' Load the Excel workbook from a file
Private workBook As WorkBook = WorkBook.Load("sample.xlsx")
' Check if the workbook is loaded successfully
If workBook Is Nothing Then
Console.WriteLine("Failed to load the workbook.")
Return
End If
' Set metadata properties for the workbook
workBook.Metadata.Author = "Your Name" ' Specify the author of the document
workBook.Metadata.Comments = "Monthly report" ' Add comments to describe the document
workBook.Metadata.Title = "July" ' Set the title of the document
workBook.Metadata.Keywords = "Report" ' Add keywords for better searching
' Read the creation date of the Excel file
Dim creationDate? As DateTime = workBook.Metadata.Created
' Optional: Output the creation date to the console for verification
If creationDate.HasValue Then
Console.WriteLine($"File creation date: {creationDate.Value}")
Else
Console.WriteLine("Creation date is not available.")
End If
' Read the last printed date of the Excel file
Dim printDate? As DateTime = workBook.Metadata.LastPrinted
' Optional: Output the last printed date to the console for verification
If printDate.HasValue Then
Console.WriteLine($"File last printed date: {printDate.Value}")
Else
Console.WriteLine("Last printed date is not available.")
End If
' Save the workbook with the new metadata
Try
workBook.SaveAs("editedMetadata.xlsx")
Console.WriteLine("Workbook saved successfully with updated metadata.")
Catch ex As Exception
Console.WriteLine($"Failed to save the workbook. Error: {ex.Message}")
End Try

Accessible Metadata Fields
Not all metadata properties can be edited or changed. Some properties can only be retrieved. Below is a list of the available properties:
Set, Modify, and Retrieve
- Author
- Comments
- LastPrinted
- Keywords and Category
- Created and ModifiedDate
- Subject and Title
Retrieve Only
- ApplicationName
- CustomProperties
- Company
- Manager
- Template
Frequently Asked Questions
What is workbook metadata in Excel?
Workbook metadata in Excel includes information such as the title, author, subject, keywords, creation date, modification date, and other relevant details that provide context and help in organizing spreadsheets.
How can I edit workbook metadata without using Office Interop?
You can edit workbook metadata without using Office Interop by utilizing the IronXL library in C#. This library allows you to access and modify metadata properties like author, title, and subject directly.
What are the steps to edit workbook metadata using IronXL?
To edit workbook metadata using IronXL, download the library, load or create a spreadsheet, access the Metadata property to modify details, and then save the spreadsheet with updated metadata.
Can you provide a code example for setting the author property in workbook metadata?
Yes, you can set the author property by using the following code: `workBook.Metadata.Author = "Your Name";` This updates the author field in the workbook metadata.
What metadata properties can be modified using IronXL?
Using IronXL, you can modify metadata properties such as Author, Comments, LastPrinted, Keywords, Category, Created and ModifiedDate, Subject, and Title.
Are there any metadata properties that can only be retrieved but not modified?
Yes, some metadata properties like ApplicationName, CustomProperties, Company, Manager, and Template can only be retrieved and not modified using IronXL.
What is the advantage of editing workbook metadata?
Editing workbook metadata provides better context, helps in organizing and categorizing spreadsheets, and simplifies file search and management, especially with multiple files.
Does IronXL support creating a new workbook while editing metadata?
Yes, IronXL supports both loading an existing workbook and creating a new one, allowing you to edit metadata in both scenarios.
How do I save a workbook after editing its metadata using IronXL?
After editing the metadata, you can save the workbook using the `SaveAs` method. For example: `workBook.SaveAs("updatedWorkbook.xlsx");`
Where can I download the IronXL library?
The IronXL library can be downloaded from the NuGet package repository at https://nuget.org/packages/IronXL.Excel/