Workbook Document Properties
- 3 minutes to read
Workbook document properties store workbook metadata, such as title, author, subject, keywords, description, and creation date. Document management systems and other applications can use these properties to identify and organize workbook files.
Built-In Document Properties
Use the Workbook.DocumentProperties property to access the following built-in document properties:
| Property | Description | Auto Updated | Read Only |
|---|---|---|---|
| Title | Specifies the workbook title. | No | No |
| Subject | Specifies the workbook subject or brief description. | No | No |
| Author | Specifies the workbook author. | No | No |
| Keywords | Specifies keywords associated with the workbook. Separate multiple keywords with commas. | No | No |
| Description | Specifies the workbook description. | No | No |
| LastModifiedBy | Specifies the user who last modified the workbook. | Yes | No |
| Category | Specifies the workbook category. | No | No |
| Created | Specifies the workbook creation date and time. | Yes | No |
| Modified | Specifies the date and time of the most recent workbook modification. | Yes | No |
| Printed | Specifies the most recent workbook print date and time. | Yes | No |
| ContentStatus | Specifies the workbook content status. | No | No |
| DocumentRevision | Specifies the workbook revision number. The value must be a non-negative whole number. | No | No |
| DocumentVersion | Specifies the workbook version number. The value must be a non-negative whole number. | No | No |
| Application | Specifies the application associated with the workbook. | No | No |
| Version | Specifies the application version. The value must follow the X.Y format, where X contains one or two digits and Y contains one to four digits. |
No | No |
| Manager | Specifies the manager associated with the workbook. | No | No |
| Company | Specifies the company associated with the workbook. | No | No |
| Security | Specifies the workbook security status. | No | Yes |
| CustomProperties | Contains custom workbook properties. | No | No |
The following code snippet specifies Title, Author, and Subject document properties:
using System;
using System.IO;
using DevExpress.Docs.Spreadsheet;
Directory.CreateDirectory("output");
using Workbook workbook = new Workbook();
workbook.DocumentProperties.Title = "Sales Report";
workbook.DocumentProperties.Author = "John Doe";
workbook.DocumentProperties.Subject = "Annual sales report";
using FileStream stream = File.Create(Path.Combine("output", "Document.xlsx"));
workbook.Save(stream);
Note
You can preserve built-in document properties when you export a workbook to PDF.
Use the PdfExportOptions.MetadataExportMode property to specify how the PDF export obtains document metadata. The SourceDocumentProperties mode uses metadata from the source workbook. The Merge mode uses metadata from PDF document options when specified and uses the corresponding workbook properties for unspecified values.
Custom Document Properties
Use the Workbook.DocumentProperties.CustomProperties collection to add, access, modify, and remove custom properties.
A custom property has a name and a value. Supported value types include:
StringBooleanIntDoubleDateTime
The following code snippet adds custom properties to the workbook:
using System.IO;
using DevExpress.Docs.Spreadsheet;
Directory.CreateDirectory("output");
using Workbook workbook = new Workbook();
workbook.DocumentProperties.CustomProperties.Add("Department", "Sales");
workbook.DocumentProperties.CustomProperties.Add("Reviewed", true);
using FileStream stream = File.Create(Path.Combine("output", "Document.xlsx"));
workbook.Save(stream);