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.

Excel file's built-in and custom document properties
Screenshot of document properties from Excel file
Upload your file (Drag file here)
using GemBox.Spreadsheet;

class Program
{
    static void Main()
    {
        // If using 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 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

Want more?

Next example GitHub

Check the next example or select an example from the menu. You can also download our examples from the GitHub.


Like it?

Download Buy

If you want to try the GemBox.Spreadsheet yourself, you can download the free version. It delivers the same performance and set of features as the professional version, but with some operations limited. To remove the limitation, you need to purchase a license.