Example usage for org.apache.poi.xwpf.usermodel XWPFDocument createStyles

List of usage examples for org.apache.poi.xwpf.usermodel XWPFDocument createStyles

Introduction

In this page you can find the example usage for org.apache.poi.xwpf.usermodel XWPFDocument createStyles.

Prototype

public XWPFStyles createStyles() 

Source Link

Document

Creates an empty styles for the document if one does not already exist

Usage

From source file:org.obeonetwork.m2doc.generator.UserContentRawCopy.java

License:Open Source License

/**
 * Copy Table Style.//from   w w w .j  a v a2 s.c o m
 * 
 * @param inputTable
 *            input Table
 * @param outputDoc
 *            outputDoc where copy style
 * @throws IOException
 *             if the copy fails
 */
private static void copyTableStyle(XWPFTable inputTable, XWPFDocument outputDoc) throws IOException {
    try (XWPFDocument inputDoc = inputTable.getBody().getXWPFDocument();) {
        XWPFStyle style = inputDoc.getStyles().getStyle(inputTable.getStyleID());
        if (outputDoc == null || style == null) {
            return;
        }

        if (outputDoc.getStyles() == null) {
            outputDoc.createStyles();
        }

        List<XWPFStyle> usedStyleList = inputDoc.getStyles().getUsedStyleList(style);
        for (XWPFStyle xwpfStyle : usedStyleList) {
            outputDoc.getStyles().addStyle(xwpfStyle);
        }
    }
}