Example usage for org.apache.poi.xssf.usermodel XSSFWorkbook getProperties

List of usage examples for org.apache.poi.xssf.usermodel XSSFWorkbook getProperties

Introduction

In this page you can find the example usage for org.apache.poi.xssf.usermodel XSSFWorkbook getProperties.

Prototype

public POIXMLProperties getProperties() 

Source Link

Document

Get the document properties.

Usage

From source file:packtest.WorkbookProperties.java

License:Apache License

public static void main(String[] args) throws Exception {

    XSSFWorkbook workbook = new XSSFWorkbook();
    workbook.createSheet("Workbook Properties");

    POIXMLProperties props = workbook.getProperties();

    /**// ww  w.j a  va2 s .  co m
     * Extended properties are a predefined set of metadata properties
     * that are specifically applicable to Office Open XML documents.
     * Extended properties consist of 24 simple properties and 3 complex properties stored in the
     *  part targeted by the relationship of type
     */
    POIXMLProperties.ExtendedProperties ext = props.getExtendedProperties();
    ext.getUnderlyingProperties().setCompany("Apache Software Foundation");
    ext.getUnderlyingProperties().setTemplate("XSSF");

    /**
     * Custom properties enable users to define custom metadata properties.
     */

    POIXMLProperties.CustomProperties cust = props.getCustomProperties();
    cust.addProperty("Author", "John Smith");
    cust.addProperty("Year", 2009);
    cust.addProperty("Price", 45.50);
    cust.addProperty("Available", true);

    FileOutputStream out = new FileOutputStream(Utils.getPath("workbook.xlsx"));
    workbook.write(out);
    out.close();

}

From source file:poi.xssf.usermodel.examples.WorkbookProperties.java

License:Apache License

public static void main(String[] args) throws Exception {

    XSSFWorkbook workbook = new XSSFWorkbook();
    workbook.createSheet("Workbook Properties");

    POIXMLProperties props = workbook.getProperties();

    /**/*from ww w .j a  v a 2s . co  m*/
     * Extended properties are a predefined set of metadata properties
     * that are specifically applicable to Office Open XML documents.
     * Extended properties consist of 24 simple properties and 3 complex properties stored in the
     *  part targeted by the relationship of type
     */
    POIXMLProperties.ExtendedProperties ext = props.getExtendedProperties();
    ext.getUnderlyingProperties().setCompany("Apache Software Foundation");
    ext.getUnderlyingProperties().setTemplate("XSSF");

    /**
     * Custom properties enable users to define custom metadata properties.
     */

    POIXMLProperties.CustomProperties cust = props.getCustomProperties();
    cust.addProperty("Author", "John Smith");
    cust.addProperty("Year", 2009);
    cust.addProperty("Price", 45.50);
    cust.addProperty("Available", true);

    FileOutputStream out = new FileOutputStream("workbook.xlsx");
    workbook.write(out);
    out.close();

}