Class SimpleTable


  • public class SimpleTable
    extends Object
    This program creates a simple WordprocessingML table using POI XWPF API, and a more complex, styled table using both XWPF and poi-ooxml-full. It's possible that not all referenced wordprocessingml classes are defined in the poi-ooxml-lite jar. If this is the case, you'll need to use the poi-ooxml-full jar library.
    • Constructor Detail

      • SimpleTable

        public SimpleTable()
    • Method Detail

      • createSimpleTable

        public static void createSimpleTable()
                                      throws Exception
        Throws:
        Exception
      • createStyledTable

        public static void createStyledTable()
                                      throws Exception
        Create a table with some row and column styling. I "manually" add the style name to the table, but don't check to see if the style actually exists in the document. Since I'm creating it from scratch, it obviously won't exist. When opened in MS Word, the table style becomes "Normal". I manually set alternating row colors. This could be done using Themes, but that's left as an exercise for the reader. The cells in the last column of the table have 10pt. "Courier" font. I make no claims that this is the "right" way to do it, but it worked for me. Given the scarcity of XWPF examples, I thought this may prove instructive and give you ideas for your own solutions.
        Throws:
        Exception