Back to Devexpress

DocumentProperties.Custom Property

officefileapi-devexpress-dot-spreadsheet-dot-documentproperties.md

latest4.6 KB
Original Source

DocumentProperties.Custom Property

Provides access to the custom document properties associated with a workbook.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
DocumentCustomProperties Custom { get; }
vb
ReadOnly Property Custom As DocumentCustomProperties

Property Value

TypeDescription
DocumentCustomProperties

A DocumentCustomProperties object that represents all the custom document properties for a workbook.

|

Remarks

Use the Custom property to specify custom properties for a spreadsheet document. To set a value of the desired custom property, use the DocumentCustomProperties.Item property.

To remove all the user-defined properties from a workbook, use the DocumentCustomProperties.Clear method.

Note

Custom properties implementation is based on Standard ECMA-376 Office Open XML File Formats Part 4: Markup Language Reference §7.3 Custom Properties.

Example

View Example

csharp
// Set the custom document properties.
workbook.DocumentProperties.Custom["Revision"] = 3;
workbook.DocumentProperties.Custom["Completed"] = true;
workbook.DocumentProperties.Custom["Published"] = DateTime.Now;
// Display the specified custom properties in a worksheet.
IEnumerable<string> customPropertiesNames = workbook.DocumentProperties.Custom.Names;
int rowIndex = 2;
foreach (string propertyName in customPropertiesNames)
{
    worksheet[rowIndex, 1].Value = propertyName;
    worksheet[rowIndex, 2].Value = workbook.DocumentProperties.Custom[propertyName];
    if (worksheet[rowIndex, 2].Value.IsDateTime)
        worksheet[rowIndex, 2].NumberFormat = "[$-409]m/d/yyyy h:mm AM/PM";
    rowIndex++;
}
vb
' Set the custom document properties.
workbook.DocumentProperties.Custom("Revision") = 3
workbook.DocumentProperties.Custom("Completed") = True
workbook.DocumentProperties.Custom("Published") = Date.Now
' Display the specified custom properties in a worksheet.
Dim customPropertiesNames As IEnumerable(Of String) = workbook.DocumentProperties.Custom.Names
Dim rowIndex As Integer = 2
For Each propertyName As String In customPropertiesNames
    worksheet(rowIndex, 1).Value = propertyName
    worksheet(rowIndex, 2).Value = workbook.DocumentProperties.Custom(propertyName)
    If worksheet(rowIndex, 2).Value.IsDateTime Then
        worksheet(rowIndex, 2).NumberFormat = "[$-409]m/d/yyyy h:mm AM/PM"
    End If
    rowIndex += 1
Next propertyName

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Custom property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

spreadsheet-document-api-examples-part1/VB/SpreadsheetExamples/SpreadsheetActions/DocumentPropertiesActions.vb#L60

vb
' Set the custom document properties.
workbook.DocumentProperties.Custom("Revision") = 3
workbook.DocumentProperties.Custom("Completed") = True

See Also

DocumentProperties Interface

DocumentProperties Members

DevExpress.Spreadsheet Namespace