com.aspose.words

Class ConditionalStyleCollection

  • java.lang.Object
    • com.aspose.words.ConditionalStyleCollection
  • All Implemented Interfaces:
    java.lang.Iterable
    public class ConditionalStyleCollection 
    extends java.lang.Object

Represents a collection of ConditionalStyle objects.
It is not possible to add or remove items from this collection. It contains permanent set of items: one item for each value of the ConditionalStyleType enumeration type.

Example:

Shows how to work with certain area styles of a table.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Create a table, which we will partially style
Table table = builder.startTable();
builder.insertCell();
builder.write("Cell 1, to be formatted");
builder.insertCell();
builder.write("Cell 2, to be formatted");
builder.endRow();
builder.insertCell();
builder.write("Cell 3, to be left unformatted");
builder.insertCell();
builder.write("Cell 4, to be left unformatted");
builder.endTable();

TableStyle tableStyle = (TableStyle) doc.getStyles().add(StyleType.TABLE, "MyTableStyle1");
// There is a different ways how to get conditional styles:
// by conditional style type
tableStyle.getConditionalStyles().getByConditionalStyleType(ConditionalStyleType.FIRST_ROW).getShading().setBackgroundPatternColor(Color.BLUE);
// by index
tableStyle.getConditionalStyles().get(0).getBorders().setColor(Color.BLACK);
tableStyle.getConditionalStyles().get(0).getBorders().setLineStyle(LineStyle.DOT_DASH);
Assert.assertEquals(tableStyle.getConditionalStyles().get(0).getType(), ConditionalStyleType.FIRST_ROW);
// directly from ConditionalStyleCollection
tableStyle.getConditionalStyles().getFirstRow().getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
// To see this in Word document select Total Row checkbox in Design Tab
tableStyle.getConditionalStyles().getLastRow().setBottomPadding(10.0);
tableStyle.getConditionalStyles().getLastRow().setLeftPadding(10.0);
tableStyle.getConditionalStyles().getLastRow().setRightPadding(10.0);
tableStyle.getConditionalStyles().getLastRow().setTopPadding(10.0);
// To see this in Word document select Last Column checkbox in Design Tab
tableStyle.getConditionalStyles().getLastColumn().getFont().setBold(true);

System.out.println(tableStyle.getConditionalStyles().getCount());
System.out.println(tableStyle.getConditionalStyles().get(0).getType());

table = (Table) doc.getChild(NodeType.TABLE, 0, true);
table.setStyle(tableStyle);

doc.save(getArtifactsDir() + "Table.WorkWithTableConditionalStyles.docx");

Property Getters/Setters Summary
ConditionalStylegetBottomLeftCell()
Gets the bottom left cell style.
ConditionalStylegetBottomRightCell()
Gets the bottom right cell style.
intgetCount()
Gets the number of conditional styles in the collection.
ConditionalStylegetEvenColumnBanding()
Gets the even column banding style.
ConditionalStylegetEvenRowBanding()
Gets the even row banding style.
ConditionalStylegetFirstColumn()
Gets the first column style.
ConditionalStylegetFirstRow()
Gets the first row style.
ConditionalStylegetLastColumn()
Gets the last column style.
ConditionalStylegetLastRow()
Gets the last row style.
ConditionalStylegetOddColumnBanding()
Gets the odd column banding style.
ConditionalStylegetOddRowBanding()
Gets the odd row banding style.
ConditionalStylegetTopLeftCell()
Gets the top left cell style.
ConditionalStylegetTopRightCell()
Gets the top right cell style.
ConditionalStyleget(int index)
Retrieves a ConditionalStyle object by index.
ConditionalStylegetByConditionalStyleType(int conditionalStyleType)
Retrieves a ConditionalStyle object by conditional style type.
 
Method Summary
voidclearFormatting()
Clears all conditional styles of the table style.
java.util.Iterator<ConditionalStyle>iterator()
Returns an enumerator object that can be used to iterate over all conditional styles in the collection.
 

    • Property Getters/Setters Detail

      • getBottomLeftCell

        public ConditionalStyle getBottomLeftCell()
        
        Gets the bottom left cell style.

        Example:

        Shows how to work with certain area styles of a table.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a table, which we will partially style
        Table table = builder.startTable();
        builder.insertCell();
        builder.write("Cell 1, to be formatted");
        builder.insertCell();
        builder.write("Cell 2, to be formatted");
        builder.endRow();
        builder.insertCell();
        builder.write("Cell 3, to be left unformatted");
        builder.insertCell();
        builder.write("Cell 4, to be left unformatted");
        builder.endTable();
        
        TableStyle tableStyle = (TableStyle) doc.getStyles().add(StyleType.TABLE, "MyTableStyle1");
        // There is a different ways how to get conditional styles:
        // by conditional style type
        tableStyle.getConditionalStyles().getByConditionalStyleType(ConditionalStyleType.FIRST_ROW).getShading().setBackgroundPatternColor(Color.BLUE);
        // by index
        tableStyle.getConditionalStyles().get(0).getBorders().setColor(Color.BLACK);
        tableStyle.getConditionalStyles().get(0).getBorders().setLineStyle(LineStyle.DOT_DASH);
        Assert.assertEquals(tableStyle.getConditionalStyles().get(0).getType(), ConditionalStyleType.FIRST_ROW);
        // directly from ConditionalStyleCollection
        tableStyle.getConditionalStyles().getFirstRow().getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
        // To see this in Word document select Total Row checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastRow().setBottomPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setLeftPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setRightPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setTopPadding(10.0);
        // To see this in Word document select Last Column checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastColumn().getFont().setBold(true);
        
        System.out.println(tableStyle.getConditionalStyles().getCount());
        System.out.println(tableStyle.getConditionalStyles().get(0).getType());
        
        table = (Table) doc.getChild(NodeType.TABLE, 0, true);
        table.setStyle(tableStyle);
        
        doc.save(getArtifactsDir() + "Table.WorkWithTableConditionalStyles.docx");
      • getBottomRightCell

        public ConditionalStyle getBottomRightCell()
        
        Gets the bottom right cell style.

        Example:

        Shows how to work with certain area styles of a table.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a table, which we will partially style
        Table table = builder.startTable();
        builder.insertCell();
        builder.write("Cell 1, to be formatted");
        builder.insertCell();
        builder.write("Cell 2, to be formatted");
        builder.endRow();
        builder.insertCell();
        builder.write("Cell 3, to be left unformatted");
        builder.insertCell();
        builder.write("Cell 4, to be left unformatted");
        builder.endTable();
        
        TableStyle tableStyle = (TableStyle) doc.getStyles().add(StyleType.TABLE, "MyTableStyle1");
        // There is a different ways how to get conditional styles:
        // by conditional style type
        tableStyle.getConditionalStyles().getByConditionalStyleType(ConditionalStyleType.FIRST_ROW).getShading().setBackgroundPatternColor(Color.BLUE);
        // by index
        tableStyle.getConditionalStyles().get(0).getBorders().setColor(Color.BLACK);
        tableStyle.getConditionalStyles().get(0).getBorders().setLineStyle(LineStyle.DOT_DASH);
        Assert.assertEquals(tableStyle.getConditionalStyles().get(0).getType(), ConditionalStyleType.FIRST_ROW);
        // directly from ConditionalStyleCollection
        tableStyle.getConditionalStyles().getFirstRow().getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
        // To see this in Word document select Total Row checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastRow().setBottomPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setLeftPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setRightPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setTopPadding(10.0);
        // To see this in Word document select Last Column checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastColumn().getFont().setBold(true);
        
        System.out.println(tableStyle.getConditionalStyles().getCount());
        System.out.println(tableStyle.getConditionalStyles().get(0).getType());
        
        table = (Table) doc.getChild(NodeType.TABLE, 0, true);
        table.setStyle(tableStyle);
        
        doc.save(getArtifactsDir() + "Table.WorkWithTableConditionalStyles.docx");
      • getCount

        public int getCount()
        
        Gets the number of conditional styles in the collection.

        Example:

        Shows how to work with certain area styles of a table.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a table, which we will partially style
        Table table = builder.startTable();
        builder.insertCell();
        builder.write("Cell 1, to be formatted");
        builder.insertCell();
        builder.write("Cell 2, to be formatted");
        builder.endRow();
        builder.insertCell();
        builder.write("Cell 3, to be left unformatted");
        builder.insertCell();
        builder.write("Cell 4, to be left unformatted");
        builder.endTable();
        
        TableStyle tableStyle = (TableStyle) doc.getStyles().add(StyleType.TABLE, "MyTableStyle1");
        // There is a different ways how to get conditional styles:
        // by conditional style type
        tableStyle.getConditionalStyles().getByConditionalStyleType(ConditionalStyleType.FIRST_ROW).getShading().setBackgroundPatternColor(Color.BLUE);
        // by index
        tableStyle.getConditionalStyles().get(0).getBorders().setColor(Color.BLACK);
        tableStyle.getConditionalStyles().get(0).getBorders().setLineStyle(LineStyle.DOT_DASH);
        Assert.assertEquals(tableStyle.getConditionalStyles().get(0).getType(), ConditionalStyleType.FIRST_ROW);
        // directly from ConditionalStyleCollection
        tableStyle.getConditionalStyles().getFirstRow().getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
        // To see this in Word document select Total Row checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastRow().setBottomPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setLeftPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setRightPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setTopPadding(10.0);
        // To see this in Word document select Last Column checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastColumn().getFont().setBold(true);
        
        System.out.println(tableStyle.getConditionalStyles().getCount());
        System.out.println(tableStyle.getConditionalStyles().get(0).getType());
        
        table = (Table) doc.getChild(NodeType.TABLE, 0, true);
        table.setStyle(tableStyle);
        
        doc.save(getArtifactsDir() + "Table.WorkWithTableConditionalStyles.docx");
      • getEvenColumnBanding

        public ConditionalStyle getEvenColumnBanding()
        
        Gets the even column banding style.

        Example:

        Shows how to work with certain area styles of a table.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a table, which we will partially style
        Table table = builder.startTable();
        builder.insertCell();
        builder.write("Cell 1, to be formatted");
        builder.insertCell();
        builder.write("Cell 2, to be formatted");
        builder.endRow();
        builder.insertCell();
        builder.write("Cell 3, to be left unformatted");
        builder.insertCell();
        builder.write("Cell 4, to be left unformatted");
        builder.endTable();
        
        TableStyle tableStyle = (TableStyle) doc.getStyles().add(StyleType.TABLE, "MyTableStyle1");
        // There is a different ways how to get conditional styles:
        // by conditional style type
        tableStyle.getConditionalStyles().getByConditionalStyleType(ConditionalStyleType.FIRST_ROW).getShading().setBackgroundPatternColor(Color.BLUE);
        // by index
        tableStyle.getConditionalStyles().get(0).getBorders().setColor(Color.BLACK);
        tableStyle.getConditionalStyles().get(0).getBorders().setLineStyle(LineStyle.DOT_DASH);
        Assert.assertEquals(tableStyle.getConditionalStyles().get(0).getType(), ConditionalStyleType.FIRST_ROW);
        // directly from ConditionalStyleCollection
        tableStyle.getConditionalStyles().getFirstRow().getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
        // To see this in Word document select Total Row checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastRow().setBottomPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setLeftPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setRightPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setTopPadding(10.0);
        // To see this in Word document select Last Column checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastColumn().getFont().setBold(true);
        
        System.out.println(tableStyle.getConditionalStyles().getCount());
        System.out.println(tableStyle.getConditionalStyles().get(0).getType());
        
        table = (Table) doc.getChild(NodeType.TABLE, 0, true);
        table.setStyle(tableStyle);
        
        doc.save(getArtifactsDir() + "Table.WorkWithTableConditionalStyles.docx");
      • getEvenRowBanding

        public ConditionalStyle getEvenRowBanding()
        
        Gets the even row banding style.

        Example:

        Shows how to work with certain area styles of a table.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a table, which we will partially style
        Table table = builder.startTable();
        builder.insertCell();
        builder.write("Cell 1, to be formatted");
        builder.insertCell();
        builder.write("Cell 2, to be formatted");
        builder.endRow();
        builder.insertCell();
        builder.write("Cell 3, to be left unformatted");
        builder.insertCell();
        builder.write("Cell 4, to be left unformatted");
        builder.endTable();
        
        TableStyle tableStyle = (TableStyle) doc.getStyles().add(StyleType.TABLE, "MyTableStyle1");
        // There is a different ways how to get conditional styles:
        // by conditional style type
        tableStyle.getConditionalStyles().getByConditionalStyleType(ConditionalStyleType.FIRST_ROW).getShading().setBackgroundPatternColor(Color.BLUE);
        // by index
        tableStyle.getConditionalStyles().get(0).getBorders().setColor(Color.BLACK);
        tableStyle.getConditionalStyles().get(0).getBorders().setLineStyle(LineStyle.DOT_DASH);
        Assert.assertEquals(tableStyle.getConditionalStyles().get(0).getType(), ConditionalStyleType.FIRST_ROW);
        // directly from ConditionalStyleCollection
        tableStyle.getConditionalStyles().getFirstRow().getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
        // To see this in Word document select Total Row checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastRow().setBottomPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setLeftPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setRightPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setTopPadding(10.0);
        // To see this in Word document select Last Column checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastColumn().getFont().setBold(true);
        
        System.out.println(tableStyle.getConditionalStyles().getCount());
        System.out.println(tableStyle.getConditionalStyles().get(0).getType());
        
        table = (Table) doc.getChild(NodeType.TABLE, 0, true);
        table.setStyle(tableStyle);
        
        doc.save(getArtifactsDir() + "Table.WorkWithTableConditionalStyles.docx");
      • getFirstColumn

        public ConditionalStyle getFirstColumn()
        
        Gets the first column style.

        Example:

        Shows how to work with certain area styles of a table.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a table, which we will partially style
        Table table = builder.startTable();
        builder.insertCell();
        builder.write("Cell 1, to be formatted");
        builder.insertCell();
        builder.write("Cell 2, to be formatted");
        builder.endRow();
        builder.insertCell();
        builder.write("Cell 3, to be left unformatted");
        builder.insertCell();
        builder.write("Cell 4, to be left unformatted");
        builder.endTable();
        
        TableStyle tableStyle = (TableStyle) doc.getStyles().add(StyleType.TABLE, "MyTableStyle1");
        // There is a different ways how to get conditional styles:
        // by conditional style type
        tableStyle.getConditionalStyles().getByConditionalStyleType(ConditionalStyleType.FIRST_ROW).getShading().setBackgroundPatternColor(Color.BLUE);
        // by index
        tableStyle.getConditionalStyles().get(0).getBorders().setColor(Color.BLACK);
        tableStyle.getConditionalStyles().get(0).getBorders().setLineStyle(LineStyle.DOT_DASH);
        Assert.assertEquals(tableStyle.getConditionalStyles().get(0).getType(), ConditionalStyleType.FIRST_ROW);
        // directly from ConditionalStyleCollection
        tableStyle.getConditionalStyles().getFirstRow().getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
        // To see this in Word document select Total Row checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastRow().setBottomPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setLeftPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setRightPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setTopPadding(10.0);
        // To see this in Word document select Last Column checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastColumn().getFont().setBold(true);
        
        System.out.println(tableStyle.getConditionalStyles().getCount());
        System.out.println(tableStyle.getConditionalStyles().get(0).getType());
        
        table = (Table) doc.getChild(NodeType.TABLE, 0, true);
        table.setStyle(tableStyle);
        
        doc.save(getArtifactsDir() + "Table.WorkWithTableConditionalStyles.docx");
      • getFirstRow

        public ConditionalStyle getFirstRow()
        
        Gets the first row style.

        Example:

        Shows how to work with certain area styles of a table.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a table, which we will partially style
        Table table = builder.startTable();
        builder.insertCell();
        builder.write("Cell 1, to be formatted");
        builder.insertCell();
        builder.write("Cell 2, to be formatted");
        builder.endRow();
        builder.insertCell();
        builder.write("Cell 3, to be left unformatted");
        builder.insertCell();
        builder.write("Cell 4, to be left unformatted");
        builder.endTable();
        
        TableStyle tableStyle = (TableStyle) doc.getStyles().add(StyleType.TABLE, "MyTableStyle1");
        // There is a different ways how to get conditional styles:
        // by conditional style type
        tableStyle.getConditionalStyles().getByConditionalStyleType(ConditionalStyleType.FIRST_ROW).getShading().setBackgroundPatternColor(Color.BLUE);
        // by index
        tableStyle.getConditionalStyles().get(0).getBorders().setColor(Color.BLACK);
        tableStyle.getConditionalStyles().get(0).getBorders().setLineStyle(LineStyle.DOT_DASH);
        Assert.assertEquals(tableStyle.getConditionalStyles().get(0).getType(), ConditionalStyleType.FIRST_ROW);
        // directly from ConditionalStyleCollection
        tableStyle.getConditionalStyles().getFirstRow().getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
        // To see this in Word document select Total Row checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastRow().setBottomPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setLeftPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setRightPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setTopPadding(10.0);
        // To see this in Word document select Last Column checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastColumn().getFont().setBold(true);
        
        System.out.println(tableStyle.getConditionalStyles().getCount());
        System.out.println(tableStyle.getConditionalStyles().get(0).getType());
        
        table = (Table) doc.getChild(NodeType.TABLE, 0, true);
        table.setStyle(tableStyle);
        
        doc.save(getArtifactsDir() + "Table.WorkWithTableConditionalStyles.docx");
      • getLastColumn

        public ConditionalStyle getLastColumn()
        
        Gets the last column style.

        Example:

        Shows how to work with certain area styles of a table.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a table, which we will partially style
        Table table = builder.startTable();
        builder.insertCell();
        builder.write("Cell 1, to be formatted");
        builder.insertCell();
        builder.write("Cell 2, to be formatted");
        builder.endRow();
        builder.insertCell();
        builder.write("Cell 3, to be left unformatted");
        builder.insertCell();
        builder.write("Cell 4, to be left unformatted");
        builder.endTable();
        
        TableStyle tableStyle = (TableStyle) doc.getStyles().add(StyleType.TABLE, "MyTableStyle1");
        // There is a different ways how to get conditional styles:
        // by conditional style type
        tableStyle.getConditionalStyles().getByConditionalStyleType(ConditionalStyleType.FIRST_ROW).getShading().setBackgroundPatternColor(Color.BLUE);
        // by index
        tableStyle.getConditionalStyles().get(0).getBorders().setColor(Color.BLACK);
        tableStyle.getConditionalStyles().get(0).getBorders().setLineStyle(LineStyle.DOT_DASH);
        Assert.assertEquals(tableStyle.getConditionalStyles().get(0).getType(), ConditionalStyleType.FIRST_ROW);
        // directly from ConditionalStyleCollection
        tableStyle.getConditionalStyles().getFirstRow().getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
        // To see this in Word document select Total Row checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastRow().setBottomPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setLeftPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setRightPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setTopPadding(10.0);
        // To see this in Word document select Last Column checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastColumn().getFont().setBold(true);
        
        System.out.println(tableStyle.getConditionalStyles().getCount());
        System.out.println(tableStyle.getConditionalStyles().get(0).getType());
        
        table = (Table) doc.getChild(NodeType.TABLE, 0, true);
        table.setStyle(tableStyle);
        
        doc.save(getArtifactsDir() + "Table.WorkWithTableConditionalStyles.docx");
      • getLastRow

        public ConditionalStyle getLastRow()
        
        Gets the last row style.

        Example:

        Shows how to work with certain area styles of a table.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a table, which we will partially style
        Table table = builder.startTable();
        builder.insertCell();
        builder.write("Cell 1, to be formatted");
        builder.insertCell();
        builder.write("Cell 2, to be formatted");
        builder.endRow();
        builder.insertCell();
        builder.write("Cell 3, to be left unformatted");
        builder.insertCell();
        builder.write("Cell 4, to be left unformatted");
        builder.endTable();
        
        TableStyle tableStyle = (TableStyle) doc.getStyles().add(StyleType.TABLE, "MyTableStyle1");
        // There is a different ways how to get conditional styles:
        // by conditional style type
        tableStyle.getConditionalStyles().getByConditionalStyleType(ConditionalStyleType.FIRST_ROW).getShading().setBackgroundPatternColor(Color.BLUE);
        // by index
        tableStyle.getConditionalStyles().get(0).getBorders().setColor(Color.BLACK);
        tableStyle.getConditionalStyles().get(0).getBorders().setLineStyle(LineStyle.DOT_DASH);
        Assert.assertEquals(tableStyle.getConditionalStyles().get(0).getType(), ConditionalStyleType.FIRST_ROW);
        // directly from ConditionalStyleCollection
        tableStyle.getConditionalStyles().getFirstRow().getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
        // To see this in Word document select Total Row checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastRow().setBottomPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setLeftPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setRightPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setTopPadding(10.0);
        // To see this in Word document select Last Column checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastColumn().getFont().setBold(true);
        
        System.out.println(tableStyle.getConditionalStyles().getCount());
        System.out.println(tableStyle.getConditionalStyles().get(0).getType());
        
        table = (Table) doc.getChild(NodeType.TABLE, 0, true);
        table.setStyle(tableStyle);
        
        doc.save(getArtifactsDir() + "Table.WorkWithTableConditionalStyles.docx");
      • getOddColumnBanding

        public ConditionalStyle getOddColumnBanding()
        
        Gets the odd column banding style.

        Example:

        Shows how to work with certain area styles of a table.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a table, which we will partially style
        Table table = builder.startTable();
        builder.insertCell();
        builder.write("Cell 1, to be formatted");
        builder.insertCell();
        builder.write("Cell 2, to be formatted");
        builder.endRow();
        builder.insertCell();
        builder.write("Cell 3, to be left unformatted");
        builder.insertCell();
        builder.write("Cell 4, to be left unformatted");
        builder.endTable();
        
        TableStyle tableStyle = (TableStyle) doc.getStyles().add(StyleType.TABLE, "MyTableStyle1");
        // There is a different ways how to get conditional styles:
        // by conditional style type
        tableStyle.getConditionalStyles().getByConditionalStyleType(ConditionalStyleType.FIRST_ROW).getShading().setBackgroundPatternColor(Color.BLUE);
        // by index
        tableStyle.getConditionalStyles().get(0).getBorders().setColor(Color.BLACK);
        tableStyle.getConditionalStyles().get(0).getBorders().setLineStyle(LineStyle.DOT_DASH);
        Assert.assertEquals(tableStyle.getConditionalStyles().get(0).getType(), ConditionalStyleType.FIRST_ROW);
        // directly from ConditionalStyleCollection
        tableStyle.getConditionalStyles().getFirstRow().getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
        // To see this in Word document select Total Row checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastRow().setBottomPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setLeftPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setRightPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setTopPadding(10.0);
        // To see this in Word document select Last Column checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastColumn().getFont().setBold(true);
        
        System.out.println(tableStyle.getConditionalStyles().getCount());
        System.out.println(tableStyle.getConditionalStyles().get(0).getType());
        
        table = (Table) doc.getChild(NodeType.TABLE, 0, true);
        table.setStyle(tableStyle);
        
        doc.save(getArtifactsDir() + "Table.WorkWithTableConditionalStyles.docx");
      • getOddRowBanding

        public ConditionalStyle getOddRowBanding()
        
        Gets the odd row banding style.

        Example:

        Shows how to work with certain area styles of a table.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a table, which we will partially style
        Table table = builder.startTable();
        builder.insertCell();
        builder.write("Cell 1, to be formatted");
        builder.insertCell();
        builder.write("Cell 2, to be formatted");
        builder.endRow();
        builder.insertCell();
        builder.write("Cell 3, to be left unformatted");
        builder.insertCell();
        builder.write("Cell 4, to be left unformatted");
        builder.endTable();
        
        TableStyle tableStyle = (TableStyle) doc.getStyles().add(StyleType.TABLE, "MyTableStyle1");
        // There is a different ways how to get conditional styles:
        // by conditional style type
        tableStyle.getConditionalStyles().getByConditionalStyleType(ConditionalStyleType.FIRST_ROW).getShading().setBackgroundPatternColor(Color.BLUE);
        // by index
        tableStyle.getConditionalStyles().get(0).getBorders().setColor(Color.BLACK);
        tableStyle.getConditionalStyles().get(0).getBorders().setLineStyle(LineStyle.DOT_DASH);
        Assert.assertEquals(tableStyle.getConditionalStyles().get(0).getType(), ConditionalStyleType.FIRST_ROW);
        // directly from ConditionalStyleCollection
        tableStyle.getConditionalStyles().getFirstRow().getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
        // To see this in Word document select Total Row checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastRow().setBottomPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setLeftPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setRightPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setTopPadding(10.0);
        // To see this in Word document select Last Column checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastColumn().getFont().setBold(true);
        
        System.out.println(tableStyle.getConditionalStyles().getCount());
        System.out.println(tableStyle.getConditionalStyles().get(0).getType());
        
        table = (Table) doc.getChild(NodeType.TABLE, 0, true);
        table.setStyle(tableStyle);
        
        doc.save(getArtifactsDir() + "Table.WorkWithTableConditionalStyles.docx");
      • getTopLeftCell

        public ConditionalStyle getTopLeftCell()
        
        Gets the top left cell style.

        Example:

        Shows how to work with certain area styles of a table.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a table, which we will partially style
        Table table = builder.startTable();
        builder.insertCell();
        builder.write("Cell 1, to be formatted");
        builder.insertCell();
        builder.write("Cell 2, to be formatted");
        builder.endRow();
        builder.insertCell();
        builder.write("Cell 3, to be left unformatted");
        builder.insertCell();
        builder.write("Cell 4, to be left unformatted");
        builder.endTable();
        
        TableStyle tableStyle = (TableStyle) doc.getStyles().add(StyleType.TABLE, "MyTableStyle1");
        // There is a different ways how to get conditional styles:
        // by conditional style type
        tableStyle.getConditionalStyles().getByConditionalStyleType(ConditionalStyleType.FIRST_ROW).getShading().setBackgroundPatternColor(Color.BLUE);
        // by index
        tableStyle.getConditionalStyles().get(0).getBorders().setColor(Color.BLACK);
        tableStyle.getConditionalStyles().get(0).getBorders().setLineStyle(LineStyle.DOT_DASH);
        Assert.assertEquals(tableStyle.getConditionalStyles().get(0).getType(), ConditionalStyleType.FIRST_ROW);
        // directly from ConditionalStyleCollection
        tableStyle.getConditionalStyles().getFirstRow().getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
        // To see this in Word document select Total Row checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastRow().setBottomPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setLeftPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setRightPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setTopPadding(10.0);
        // To see this in Word document select Last Column checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastColumn().getFont().setBold(true);
        
        System.out.println(tableStyle.getConditionalStyles().getCount());
        System.out.println(tableStyle.getConditionalStyles().get(0).getType());
        
        table = (Table) doc.getChild(NodeType.TABLE, 0, true);
        table.setStyle(tableStyle);
        
        doc.save(getArtifactsDir() + "Table.WorkWithTableConditionalStyles.docx");
      • getTopRightCell

        public ConditionalStyle getTopRightCell()
        
        Gets the top right cell style.

        Example:

        Shows how to work with certain area styles of a table.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a table, which we will partially style
        Table table = builder.startTable();
        builder.insertCell();
        builder.write("Cell 1, to be formatted");
        builder.insertCell();
        builder.write("Cell 2, to be formatted");
        builder.endRow();
        builder.insertCell();
        builder.write("Cell 3, to be left unformatted");
        builder.insertCell();
        builder.write("Cell 4, to be left unformatted");
        builder.endTable();
        
        TableStyle tableStyle = (TableStyle) doc.getStyles().add(StyleType.TABLE, "MyTableStyle1");
        // There is a different ways how to get conditional styles:
        // by conditional style type
        tableStyle.getConditionalStyles().getByConditionalStyleType(ConditionalStyleType.FIRST_ROW).getShading().setBackgroundPatternColor(Color.BLUE);
        // by index
        tableStyle.getConditionalStyles().get(0).getBorders().setColor(Color.BLACK);
        tableStyle.getConditionalStyles().get(0).getBorders().setLineStyle(LineStyle.DOT_DASH);
        Assert.assertEquals(tableStyle.getConditionalStyles().get(0).getType(), ConditionalStyleType.FIRST_ROW);
        // directly from ConditionalStyleCollection
        tableStyle.getConditionalStyles().getFirstRow().getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
        // To see this in Word document select Total Row checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastRow().setBottomPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setLeftPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setRightPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setTopPadding(10.0);
        // To see this in Word document select Last Column checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastColumn().getFont().setBold(true);
        
        System.out.println(tableStyle.getConditionalStyles().getCount());
        System.out.println(tableStyle.getConditionalStyles().get(0).getType());
        
        table = (Table) doc.getChild(NodeType.TABLE, 0, true);
        table.setStyle(tableStyle);
        
        doc.save(getArtifactsDir() + "Table.WorkWithTableConditionalStyles.docx");
      • get

        public ConditionalStyle get(int index)
        
        Retrieves a ConditionalStyle object by index.
        Parameters:
        index - Zero-based index of the conditional style to retrieve.

        Example:

        Shows how to work with certain area styles of a table.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a table, which we will partially style
        Table table = builder.startTable();
        builder.insertCell();
        builder.write("Cell 1, to be formatted");
        builder.insertCell();
        builder.write("Cell 2, to be formatted");
        builder.endRow();
        builder.insertCell();
        builder.write("Cell 3, to be left unformatted");
        builder.insertCell();
        builder.write("Cell 4, to be left unformatted");
        builder.endTable();
        
        TableStyle tableStyle = (TableStyle) doc.getStyles().add(StyleType.TABLE, "MyTableStyle1");
        // There is a different ways how to get conditional styles:
        // by conditional style type
        tableStyle.getConditionalStyles().getByConditionalStyleType(ConditionalStyleType.FIRST_ROW).getShading().setBackgroundPatternColor(Color.BLUE);
        // by index
        tableStyle.getConditionalStyles().get(0).getBorders().setColor(Color.BLACK);
        tableStyle.getConditionalStyles().get(0).getBorders().setLineStyle(LineStyle.DOT_DASH);
        Assert.assertEquals(tableStyle.getConditionalStyles().get(0).getType(), ConditionalStyleType.FIRST_ROW);
        // directly from ConditionalStyleCollection
        tableStyle.getConditionalStyles().getFirstRow().getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
        // To see this in Word document select Total Row checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastRow().setBottomPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setLeftPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setRightPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setTopPadding(10.0);
        // To see this in Word document select Last Column checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastColumn().getFont().setBold(true);
        
        System.out.println(tableStyle.getConditionalStyles().getCount());
        System.out.println(tableStyle.getConditionalStyles().get(0).getType());
        
        table = (Table) doc.getChild(NodeType.TABLE, 0, true);
        table.setStyle(tableStyle);
        
        doc.save(getArtifactsDir() + "Table.WorkWithTableConditionalStyles.docx");
      • getByConditionalStyleType

        public ConditionalStyle getByConditionalStyleType(int conditionalStyleType)
        
        Retrieves a ConditionalStyle object by conditional style type.
        Parameters:
        conditionalStyleType - A ConditionalStyleType value.

        Example:

        Shows how to work with certain area styles of a table.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a table, which we will partially style
        Table table = builder.startTable();
        builder.insertCell();
        builder.write("Cell 1, to be formatted");
        builder.insertCell();
        builder.write("Cell 2, to be formatted");
        builder.endRow();
        builder.insertCell();
        builder.write("Cell 3, to be left unformatted");
        builder.insertCell();
        builder.write("Cell 4, to be left unformatted");
        builder.endTable();
        
        TableStyle tableStyle = (TableStyle) doc.getStyles().add(StyleType.TABLE, "MyTableStyle1");
        // There is a different ways how to get conditional styles:
        // by conditional style type
        tableStyle.getConditionalStyles().getByConditionalStyleType(ConditionalStyleType.FIRST_ROW).getShading().setBackgroundPatternColor(Color.BLUE);
        // by index
        tableStyle.getConditionalStyles().get(0).getBorders().setColor(Color.BLACK);
        tableStyle.getConditionalStyles().get(0).getBorders().setLineStyle(LineStyle.DOT_DASH);
        Assert.assertEquals(tableStyle.getConditionalStyles().get(0).getType(), ConditionalStyleType.FIRST_ROW);
        // directly from ConditionalStyleCollection
        tableStyle.getConditionalStyles().getFirstRow().getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
        // To see this in Word document select Total Row checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastRow().setBottomPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setLeftPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setRightPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setTopPadding(10.0);
        // To see this in Word document select Last Column checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastColumn().getFont().setBold(true);
        
        System.out.println(tableStyle.getConditionalStyles().getCount());
        System.out.println(tableStyle.getConditionalStyles().get(0).getType());
        
        table = (Table) doc.getChild(NodeType.TABLE, 0, true);
        table.setStyle(tableStyle);
        
        doc.save(getArtifactsDir() + "Table.WorkWithTableConditionalStyles.docx");
    • Method Detail

      • clearFormatting

        public void clearFormatting()
        Clears all conditional styles of the table style.

        Example:

        Shows how to reset all table styles.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a table and give it conditional styling on border colors based on the row being the first or last
        builder.startTable();
        builder.insertCell();
        builder.write("First row");
        builder.endRow();
        builder.insertCell();
        builder.write("Last row");
        builder.endTable();
        
        TableStyle tableStyle = (TableStyle) doc.getStyles().add(StyleType.TABLE, "MyTableStyle1");
        tableStyle.getConditionalStyles().getFirstRow().getBorders().setColor(Color.RED);
        tableStyle.getConditionalStyles().getLastRow().getBorders().setColor(Color.BLUE);
        
        // You can reset styles from the specific table area
        tableStyle.getConditionalStyles().get(0).clearFormatting();
        Assert.assertEquals(tableStyle.getConditionalStyles().getFirstRow().getBorders().getColor().getRGB(), 0);
        
        // Or clear all table styles
        tableStyle.getConditionalStyles().clearFormatting();
        Assert.assertEquals(tableStyle.getConditionalStyles().getLastRow().getBorders().getColor().getRGB(), 0);
      • iterator

        public java.util.Iterator<ConditionalStyle> iterator()
        Returns an enumerator object that can be used to iterate over all conditional styles in the collection.

        Example:

        Shows how to work with certain area styles of a table.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a table, which we will partially style
        Table table = builder.startTable();
        builder.insertCell();
        builder.write("Cell 1, to be formatted");
        builder.insertCell();
        builder.write("Cell 2, to be formatted");
        builder.endRow();
        builder.insertCell();
        builder.write("Cell 3, to be left unformatted");
        builder.insertCell();
        builder.write("Cell 4, to be left unformatted");
        builder.endTable();
        
        TableStyle tableStyle = (TableStyle) doc.getStyles().add(StyleType.TABLE, "MyTableStyle1");
        // There is a different ways how to get conditional styles:
        // by conditional style type
        tableStyle.getConditionalStyles().getByConditionalStyleType(ConditionalStyleType.FIRST_ROW).getShading().setBackgroundPatternColor(Color.BLUE);
        // by index
        tableStyle.getConditionalStyles().get(0).getBorders().setColor(Color.BLACK);
        tableStyle.getConditionalStyles().get(0).getBorders().setLineStyle(LineStyle.DOT_DASH);
        Assert.assertEquals(tableStyle.getConditionalStyles().get(0).getType(), ConditionalStyleType.FIRST_ROW);
        // directly from ConditionalStyleCollection
        tableStyle.getConditionalStyles().getFirstRow().getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
        // To see this in Word document select Total Row checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastRow().setBottomPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setLeftPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setRightPadding(10.0);
        tableStyle.getConditionalStyles().getLastRow().setTopPadding(10.0);
        // To see this in Word document select Last Column checkbox in Design Tab
        tableStyle.getConditionalStyles().getLastColumn().getFont().setBold(true);
        
        System.out.println(tableStyle.getConditionalStyles().getCount());
        System.out.println(tableStyle.getConditionalStyles().get(0).getType());
        
        table = (Table) doc.getChild(NodeType.TABLE, 0, true);
        table.setStyle(tableStyle);
        
        doc.save(getArtifactsDir() + "Table.WorkWithTableConditionalStyles.docx");