Example usage for org.apache.poi.xwpf.usermodel XWPFTable getBody

List of usage examples for org.apache.poi.xwpf.usermodel XWPFTable getBody

Introduction

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

Prototype

@Override
    public IBody getBody() 

Source Link

Usage

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

License:Open Source License

/**
 * Copy Table Style.//from   w ww  . ja  va2  s. co  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);
        }
    }
}