Package org.openxml4j.document.wordprocessing.model.table

Examples of org.openxml4j.document.wordprocessing.model.table.TableDescription


   * @throws OpenXML4JException
   */
  private TableDescription buildTestData() throws OpenXML4JException {
    // build the table info
    int nbCol = 3;
    TableDescription tableDesc = new TableDescription(
        ParagraphAlignment.LEFT);
    // do not use the standar border, make our own, color red, with -.-
    TableBorder border = new TableBorder(BorderStyle.BORDER_STYLE_DOT_DASH,
        8, "FF0000");
    tableDesc.setBorder(border);

    // build cells and lines
    for (int lineNo = 0; lineNo < 5; lineNo++) {
      ArrayList<String> line = new ArrayList<String>();
      for (int col = 0; col < nbCol; col++) {
        line.add(new String("line=" + lineNo + " col=" + col));
      }
      // (a table line can be as simple as a list of string)
      tableDesc.appendLine(line);
    }

    // make a special configuration for a cell
    // set the size of the cell (not automatically computed by MS-Word
    tableDesc.getCellAt(1, 2)
        .setCellSize(
            new TableCellSize(TableWidthType.TABLE_WIDTH_DXA,
                (short) 4096));

    tableDesc.getCellAt(1, 2).setCellBackgroundColor("FA0000"); // set a red
                                  // background
    return tableDesc;
  }
View Full Code Here


    try {
      Package pack = Package.open(inputFile, PackageAccess.READ_WRITE);
      WordDocument docx = new WordDocument(pack);

      TableDescription tableDesc = buildTestData();
      // ADD TABLE TO DOC
      docx.appendTable(tableDesc);
      docx.save(destFile);
    } catch (Exception e) {
      logger.error(e);
View Full Code Here

TOP

Related Classes of org.openxml4j.document.wordprocessing.model.table.TableDescription

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.