Document Solutions for Excel, .NET Edition | Document Solutions
Features / Document Properties
In This Topic
    Document Properties
    In This Topic

    Document properties can be used to identify some useful details about a document like the author, subject, category, comments, created date, last saved time etc. DsExcel supports storing built-in and custom document properties which can be exported and viewed in Excel documents. A few built-in properties can also be exported to PDF documents like Author, Title, Subject, Comments, CreatedDate and LastSavedTime.

    Note: To know more about supported document properties in PDF, refer Support Document Properties.

    The IDocumentProperty interface represents the document property and provides following properties:

    The BuiltInDocumentPropertyCollection of IWorkbook interface is a collection of built-in properties. The built-in properties can be set by using BuiltInDocumentProperties property and setting the value of any built-in property like Author, Subject etc.

    The CustomDocumentPropertyCollection of IWorkbook interface provides overloaded Add methods and an AddLinkToContent method. The overloaded Add methods can be used to create new custom document properties with string, boolean, datetime, double or integer values. The AddLinkToContent method can be used to create a new document property which is linked to named cells. It provides 'name' and 'source' parameters where the 'source' is a named range. If the named range is deleted, the last value that was saved in the custom property is stored. If the named range refers to more than one cell then the value of the cell in the top left corner is used. 

    Refer to the following example code to set Author and Company (built-in properties) and add a custom document property. 

    Copy Code
    IWorkbook workbook = new Workbook();
    IWorksheet worksheet = workbook.Worksheets[0];
    worksheet.Range["A1"].Value = "hello";
    // Add a defined name.
    workbook.Names.Add("Headings", "=Sheet1!$A$1");
    //Set values for built-in document properties
    workbook.BuiltInDocumentProperties.Author = "John";
    workbook.BuiltInDocumentProperties.Company = "Google";
    // Add a custom document property.
     IDocumentProperty property = workbook.CustomDocumentProperties.AddLinkToContent("Detail", "Headings");
    var value = property.Value; // The value is "Hello".
    var type = property.Type; // The Type is String.


    The following document properties are not supported in DsExcel.