Excel File Properties
Document properties contain some additional information and details about an Excel file. They are also known as Excel file metadata and can hold information such as author, company, title, and subject.
There are two types of document properties, BuiltIn
and Custom
.
To learn how to view or change properties for an Office file using Microsoft Office applications, check this article.
The following example shows how to read and write built-in and custom document properties using C# and VB.NET.

using GemBox.Spreadsheet;
class Program
{
static void Main()
{
// If using the Professional version, put your serial key below.
SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");
var workbook = ExcelFile.Load("%InputFileName%");
var worksheet = workbook.Worksheets.InsertEmpty(0, "Properties");
workbook.Worksheets.ActiveWorksheet = worksheet;
worksheet.Rows[0].Style = workbook.Styles[BuiltInCellStyleName.Heading1];
worksheet.Columns[0].SetWidth(160, LengthUnit.Pixel);
worksheet.Columns[1].SetWidth(160, LengthUnit.Pixel);
worksheet.Columns[2].SetWidth(160, LengthUnit.Pixel);
worksheet.Columns[3].SetWidth(160, LengthUnit.Pixel);
worksheet.Cells["A1"].Value = "Built-in Property";
worksheet.Cells["B1"].Value = "Built-in Value";
worksheet.Cells["C1"].Value = "Custom Property";
worksheet.Cells["D1"].Value = "Custom Value";
int rowIndex = 1;
// Read built-in document properties.
foreach (var builtinProperty in workbook.DocumentProperties.BuiltIn)
{
worksheet.Cells[rowIndex, 0].Value = builtinProperty.Key.ToString();
worksheet.Cells[rowIndex, 1].Value = builtinProperty.Value;
++rowIndex;
}
rowIndex = 1;
// Read custom document properties.
foreach (var customProperty in workbook.DocumentProperties.Custom)
{
worksheet.Cells[rowIndex, 2].Value = customProperty.Key;
worksheet.Cells[rowIndex, 3].Value = customProperty.Value;
++rowIndex;
}
// Write or modify document properties.
workbook.DocumentProperties.BuiltIn[BuiltInDocumentProperties.Author] = "Jane Doe";
workbook.DocumentProperties.Custom["Client"] = "New Client";
workbook.Save("Document Properties.%OutputFileType%");
}
}
Imports GemBox.Spreadsheet
Module Program
Sub Main()
' If using the Professional version, put your serial key below.
SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY")
Dim workbook = ExcelFile.Load("%InputFileName%")
Dim worksheet = workbook.Worksheets.InsertEmpty(0, "Properties")
workbook.Worksheets.ActiveWorksheet = worksheet
worksheet.Rows(0).Style = workbook.Styles(BuiltInCellStyleName.Heading1)
worksheet.Columns(0).SetWidth(160, LengthUnit.Pixel)
worksheet.Columns(1).SetWidth(160, LengthUnit.Pixel)
worksheet.Columns(2).SetWidth(160, LengthUnit.Pixel)
worksheet.Columns(3).SetWidth(160, LengthUnit.Pixel)
worksheet.Cells("A1").Value = "Built-in Property"
worksheet.Cells("B1").Value = "Built-in Value"
worksheet.Cells("C1").Value = "Custom Property"
worksheet.Cells("D1").Value = "Custom Value"
Dim rowIndex As Integer = 1
' Read built-in document properties.
For Each builtinProperty In workbook.DocumentProperties.BuiltIn
worksheet.Cells(rowIndex, 0).Value = builtinProperty.Key.ToString()
worksheet.Cells(rowIndex, 1).Value = builtinProperty.Value
rowIndex = rowIndex + 1
Next
rowIndex = 1
' Read custom document properties.
For Each customProperty In workbook.DocumentProperties.Custom
worksheet.Cells(rowIndex, 2).Value = customProperty.Key
worksheet.Cells(rowIndex, 3).Value = customProperty.Value
rowIndex = rowIndex + 1
Next
' Write or modify document properties.
workbook.DocumentProperties.BuiltIn(BuiltInDocumentProperties.Author) = "Jane Doe"
workbook.DocumentProperties.Custom("Client") = "New Client"
workbook.Save("Document Properties.%OutputFileType%")
End Sub
End Module
See also
Next steps
Published: December 13, 2018 | Modified: December 19, 2022 | Author: Josip Kremenic