Documents for Excel, Java Edition Documentation
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. GcExcel 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 methods:

    The BuiltInDocumentPropertyCollection of IWorkbook interface is a collection of built-in properties. The built-in properties can be set by using getBuiltInDocumentProperties method 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
    //create a new workbook
    Workbook workbook = new Workbook();
    IWorksheet worksheet = workbook.getWorksheets().get(0);
    // Add a defined name.
    workbook.getNames().add("Headings", "=Sheet1!$A$1");
    // Set values for built-in document properties
    // Add a custom document property.
    IDocumentProperty property = workbook.getCustomDocumentProperties().addLinkToContent("aaa", "Headings");
    Object value = property.getValue(); // The value is "Hello".
    PropertyType type = property.getType(); // The Type is String.
    //save to an excel file"DocumentProperties.xlsx");


    The following document properties are not supported in GcExcel.