XlDocumentProperties.Custom Property
Provides access to the custom document properties associated with a workbook.
Namespace: DevExpress.Export.Xl
Assembly: DevExpress.Printing.v24.2.Core.dll
NuGet Package: DevExpress.Printing.Core
#Declaration
public XlDocumentCustomProperties Custom { get; }
#Property Value
Type | Description |
---|---|
Xl |
An Xl |
#Remarks
Use this property to specify custom properties for a workbook. To set a value of the desired custom property, use the XlDocumentCustomProperties.Item property.
To remove all the user-defined properties from a workbook, use the XlDocumentCustomProperties.Clear method.
#Example
This example demonstrates how to specify the standard and custom document properties for a workbook using the IXlDocument.Properties and XlDocumentProperties.Custom
properties, respectively.
Use the IXlDocument.Properties property to access the XlDocumentProperties object. This object provides a set of properties that allow you to specify basic information about a workbook, such as XlDocumentProperties.Title, XlDocumentProperties.Author, XlDocumentProperties.Subject, etc.
The XlDocumentProperties.Custom
property allows you to get access to the XlDocumentCustomProperties object, which represents a storage of custom document properties. To set a value of a custom property with the specified name, use the XlDocumentCustomProperties.Item property. You can set a custom property to any object of the String, Double, DateTime or Boolean type. The specified object will be converted to the XlCustomPropertyValue object and assigned to the custom property. To get the type of the data contained in a custom document property, use the XlCustomPropertyValue.Type property.
Note
A complete sample project is available at https://github.
// Create a new document.
using (IXlDocument document = exporter.CreateDocument(stream)) {
document.Options.Culture = CultureInfo.CurrentCulture;
// Set the built-in document properties.
document.Properties.Title = "XL Export API: document properties example";
document.Properties.Subject = "XL Export API";
document.Properties.Keywords = "XL Export, document generation";
document.Properties.Description = "How to set document properties using the XL Export API";
document.Properties.Category = "Spreadsheet";
document.Properties.Company = "DevExpress Inc.";
// Set the custom document properties.
document.Properties.Custom["Product Suite"] = "XL Export Library";
document.Properties.Custom["Revision"] = 5;
document.Properties.Custom["Date Completed"] = DateTime.Now;
document.Properties.Custom["Published"] = true;
// Generate data for the document.
using(IXlSheet sheet = document.CreateSheet()) {
sheet.SkipRows(1);
using(IXlRow row = sheet.CreateRow()) {
row.SkipCells(1);
using(IXlCell cell = row.CreateCell()) {
cell.Value = "You can view document properties using the File->Info->Properties->Advanced Properties dialog.";
}
}
}
}
#Related GitHub Examples
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.