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 the Professional version, put your serial key below.

        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 = 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;

        // 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.

        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

        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

        ' 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

GemBox.Spreadsheet is a .NET component that enables you to read, write, edit, convert, and print spreadsheet files from your .NET applications using one simple API.

Download Buy