Back to Devexpress

DocumentCustomProperties.Item[String] Property

officefileapi-devexpress-dot-spreadsheet-dot-documentcustomproperties-dot-item-x28-system-dot-string-x29.md

latest3.6 KB
Original Source

DocumentCustomProperties.Item[String] Property

Gets or sets a custom document property with the given name.

Namespace : DevExpress.Spreadsheet

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

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
CellValue this[string name] { get; set; }
vb
Property Item(name As String) As CellValue

Parameters

NameTypeDescription
nameString

A string that specifies the name of the custom property to be set or obtained.

|

Property Value

TypeDescription
CellValue

A CellValue object that is the value of the custom property.

|

Example

The example below demonstrates how to define the custom document properties for a workbook. Use the DocumentProperties.Custom property to get access to a storage of all user-defined properties specified in a document. To set an individual custom property with the specified name, use the DocumentCustomProperties.Item property.

View Example

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
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++;
}

See Also

DocumentCustomProperties Interface

DocumentCustomProperties Members

DevExpress.Spreadsheet Namespace