Test in production without watermarks.
Works wherever you need it to.
Get 30 days of fully functional product.
Have it up and running in minutes.
Full access to our support engineering team during your product trial
In this video tutorial, coders are guided through the process of editing workbook metadata using IronXL in C#. The tutorial starts with setting up a C# project in Visual Studio and ensuring IronXL is installed via the NuGet Package Manager. By navigating to the Program.cs
file, users learn to integrate IronXL into their project by adding the using IronXL;
directive at the top.
The tutorial then demonstrates loading an Excel file named sample.xlsx
using the IronXL Workbook
class. Users are shown how to add metadata such as author, title, comments, and keywords to the Excel file, broadening its informational capacity. Additionally, the tutorial explains how to retrieve and set the file creation and last printed dates. After making these changes, users save their work to a new file named edited_metadata.xlsx
. Upon execution, the program applies the changes successfully, allowing users to compare the original and edited files side by side.
The video concludes by highlighting IronXL's capabilities and encouraging viewers to explore further functionalities. Viewers are encouraged to subscribe for more tutorials and check out the IronXL software through the provided link.
Below is the corrected and enhanced C# code, properly formatted and commented:
// Ensure you have installed IronXL through the NuGet Package Manager before running this code.
using IronXL; // Import the IronXL namespace
class Program
{
static void Main(string[] args)
{
// Load the Excel file named 'sample.xlsx' into a workbook
var workbook = Workbook.Load("sample.xlsx");
// Assign metadata properties to the workbook
// Setting the author of the workbook
workbook.Metadata.Author = "Jane Doe";
// Setting the title of the workbook
workbook.Metadata.Title = "Quarterly Report";
// Setting comments or description of the workbook
workbook.Metadata.Comments = "This is an edited version of the quarterly report.";
// Adding keywords for easier searchability
workbook.Metadata.Keywords = "Q1, Report, Finance";
// Set the creation date of the workbook metadata
workbook.Metadata.Created = DateTime.Now;
// Optionally set when the workbook was last printed
// Comment this out if not applicable
// workbook.Metadata.LastPrinted = DateTime.Now;
// Save the workbook with the updated metadata to a new file
workbook.SaveAs("edited_metadata.xlsx");
// Output message signalling completion
Console.WriteLine("The metadata has been successfully updated and saved.");
}
}
// Ensure you have installed IronXL through the NuGet Package Manager before running this code.
using IronXL; // Import the IronXL namespace
class Program
{
static void Main(string[] args)
{
// Load the Excel file named 'sample.xlsx' into a workbook
var workbook = Workbook.Load("sample.xlsx");
// Assign metadata properties to the workbook
// Setting the author of the workbook
workbook.Metadata.Author = "Jane Doe";
// Setting the title of the workbook
workbook.Metadata.Title = "Quarterly Report";
// Setting comments or description of the workbook
workbook.Metadata.Comments = "This is an edited version of the quarterly report.";
// Adding keywords for easier searchability
workbook.Metadata.Keywords = "Q1, Report, Finance";
// Set the creation date of the workbook metadata
workbook.Metadata.Created = DateTime.Now;
// Optionally set when the workbook was last printed
// Comment this out if not applicable
// workbook.Metadata.LastPrinted = DateTime.Now;
// Save the workbook with the updated metadata to a new file
workbook.SaveAs("edited_metadata.xlsx");
// Output message signalling completion
Console.WriteLine("The metadata has been successfully updated and saved.");
}
}
' Ensure you have installed IronXL through the NuGet Package Manager before running this code.
Imports IronXL ' Import the IronXL namespace
Friend Class Program
Shared Sub Main(ByVal args() As String)
' Load the Excel file named 'sample.xlsx' into a workbook
Dim workbook = Workbook.Load("sample.xlsx")
' Assign metadata properties to the workbook
' Setting the author of the workbook
workbook.Metadata.Author = "Jane Doe"
' Setting the title of the workbook
workbook.Metadata.Title = "Quarterly Report"
' Setting comments or description of the workbook
workbook.Metadata.Comments = "This is an edited version of the quarterly report."
' Adding keywords for easier searchability
workbook.Metadata.Keywords = "Q1, Report, Finance"
' Set the creation date of the workbook metadata
workbook.Metadata.Created = DateTime.Now
' Optionally set when the workbook was last printed
' Comment this out if not applicable
' workbook.Metadata.LastPrinted = DateTime.Now;
' Save the workbook with the updated metadata to a new file
workbook.SaveAs("edited_metadata.xlsx")
' Output message signalling completion
Console.WriteLine("The metadata has been successfully updated and saved.")
End Sub
End Class
Further Reading: How to Edit Workbook Metadata