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.

Get started with IronXL

Start using IronXL in your project today with a free trial.

First Step:
green arrow pointer


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;

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
Metadata

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

How can I edit workbook metadata in Excel using C#?

You can edit workbook metadata using the IronXL library in C#. It allows you to modify properties such as title, author, subject, and keywords without relying on Office Interop.

What steps are involved in editing Excel workbook metadata programmatically?

To edit Excel workbook metadata programmatically, first download the IronXL library, then load or create a spreadsheet. Use the Metadata property to modify metadata details, and finally, save the spreadsheet with the updated properties.

Can I change the author of an Excel workbook using C#?

Yes, you can change the author of an Excel workbook using the IronXL library. Set the author property with workBook.Metadata.Author = "Your Name"; to update this metadata field.

Which metadata properties can be modified with IronXL?

IronXL allows modification of metadata properties such as Author, Comments, LastPrinted, Keywords, Category, Created and ModifiedDate, Subject, and Title.

Are there any limitations on modifying metadata properties with IronXL?

Yes, some metadata properties like ApplicationName, CustomProperties, Company, Manager, and Template can only be retrieved and not modified using IronXL.

Why is editing workbook metadata important?

Editing workbook metadata is crucial for providing better context, organizing, and categorizing spreadsheets, which simplifies file search and management, especially with multiple files.

How can I save a workbook after editing its metadata using C#?

After editing the workbook metadata, you can save the workbook using IronXL's SaveAs method. For example: workBook.SaveAs("updatedWorkbook.xlsx");

Where can I find the IronXL library for editing workbook metadata?

The IronXL library can be downloaded from the NuGet package repository at https://nuget.org/packages/IronXL.Excel/

What is the advantage of using IronXL for editing workbook metadata over Office Interop?

Using IronXL for editing workbook metadata is advantageous as it does not require Office Interop, making it simpler and more efficient for developers to manage Excel files programmatically.

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.