java.lang.Object
com.aspose.words.ConditionalStyleType
public class ConditionalStyleType
- extends java.lang.Object
Utility class containing constants.
Represents possible table areas to which conditional formatting may be defined in a table 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
Table table = builder.startTable();
builder.insertCell();
builder.write("Cell 1");
builder.insertCell();
builder.write("Cell 2");
builder.endRow();
builder.insertCell();
builder.write("Cell 3");
builder.insertCell();
builder.write("Cell 4");
builder.endTable();
// Create a custom table style
TableStyle tableStyle = (TableStyle) doc.getStyles().add(StyleType.TABLE, "MyTableStyle1");
// Conditional styles are formatting changes that affect only some of the cells of the table based on a predicate,
// such as the cells being in the last row
// We can access these conditional styles by style type like this
tableStyle.getConditionalStyles().getByConditionalStyleType(ConditionalStyleType.FIRST_ROW).getShading().setBackgroundPatternColor(Color.BLUE);
// The same conditional style can be accessed by index
tableStyle.getConditionalStyles().get(0).getBorders().setColor(Color.BLACK);
tableStyle.getConditionalStyles().get(0).getBorders().setLineStyle(LineStyle.DOT_DASH);
Assert.assertEquals(ConditionalStyleType.FIRST_ROW, tableStyle.getConditionalStyles().get(0).getType());
// It can also be found in the ConditionalStyles collection as an attribute
tableStyle.getConditionalStyles().getFirstRow().getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
// Apply padding and text formatting to conditional styles
tableStyle.getConditionalStyles().getLastRow().setBottomPadding(10.0);
tableStyle.getConditionalStyles().getLastRow().setLeftPadding(10.0);
tableStyle.getConditionalStyles().getLastRow().setRightPadding(10.0);
tableStyle.getConditionalStyles().getLastRow().setTopPadding(10.0);
tableStyle.getConditionalStyles().getLastColumn().getFont().setBold(true);
// List all possible style conditions
Iterator<ConditionalStyle> enumerator = tableStyle.getConditionalStyles().iterator();
while (enumerator.hasNext()) {
ConditionalStyle currentStyle = enumerator.next();
if (currentStyle != null) System.out.println(currentStyle.getType());
}
// Apply conditional style to the table
table.setStyle(tableStyle);
// Changes to the first row are enabled by the table's style options be default,
// but need to be manually enabled for some other parts, such as the last column/row
table.setStyleOptions(table.getStyleOptions() | TableStyleOptions.LAST_ROW | TableStyleOptions.LAST_COLUMN);
doc.save(getArtifactsDir() + "Table.ConditionalStyles.docx");
Field Summary |
static final int | FIRST_ROW = 0 | |
Specifies formatting of the first row of a table.
|
static final int | FIRST_COLUMN = 1 | |
Specifies formatting of the first column of a table.
|
static final int | LAST_ROW = 2 | |
Specifies formatting of the last row of a table.
|
static final int | LAST_COLUMN = 3 | |
Specifies formatting of the last column of a table.
|
static final int | ODD_ROW_BANDING = 4 | |
Specifies formatting of odd-numbered row stripe.
|
static final int | ODD_COLUMN_BANDING = 5 | |
Specifies formatting of odd-numbered column stripe.
|
static final int | EVEN_ROW_BANDING = 6 | |
Specifies formatting of even-numbered row stripe.
|
static final int | EVEN_COLUMN_BANDING = 7 | |
Specifies formatting of even-numbered column stripe.
|
static final int | TOP_LEFT_CELL = 8 | |
Specifies formatting of the top left cell of a table.
|
static final int | TOP_RIGHT_CELL = 9 | |
Specifies formatting of the top right cell of a table.
|
static final int | BOTTOM_LEFT_CELL = 10 | |
Specifies formatting of the bottom left cell of a table.
|
static final int | BOTTOM_RIGHT_CELL = 11 | |
Specifies formatting of the bottom right cell of a table.
|
FIRST_ROW = 0 | |
public static final int FIRST_ROW |
-
Specifies formatting of the first row of a table.
FIRST_COLUMN = 1 | |
public static final int FIRST_COLUMN |
-
Specifies formatting of the first column of a table.
LAST_ROW = 2 | |
public static final int LAST_ROW |
-
Specifies formatting of the last row of a table.
LAST_COLUMN = 3 | |
public static final int LAST_COLUMN |
-
Specifies formatting of the last column of a table.
ODD_ROW_BANDING = 4 | |
public static final int ODD_ROW_BANDING |
-
Specifies formatting of odd-numbered row stripe.
ODD_COLUMN_BANDING = 5 | |
public static final int ODD_COLUMN_BANDING |
-
Specifies formatting of odd-numbered column stripe.
EVEN_ROW_BANDING = 6 | |
public static final int EVEN_ROW_BANDING |
-
Specifies formatting of even-numbered row stripe.
EVEN_COLUMN_BANDING = 7 | |
public static final int EVEN_COLUMN_BANDING |
-
Specifies formatting of even-numbered column stripe.
TOP_LEFT_CELL = 8 | |
public static final int TOP_LEFT_CELL |
-
Specifies formatting of the top left cell of a table.
TOP_RIGHT_CELL = 9 | |
public static final int TOP_RIGHT_CELL |
-
Specifies formatting of the top right cell of a table.
BOTTOM_LEFT_CELL = 10 | |
public static final int BOTTOM_LEFT_CELL |
-
Specifies formatting of the bottom left cell of a table.
BOTTOM_RIGHT_CELL = 11 | |
public static final int BOTTOM_RIGHT_CELL |
-
Specifies formatting of the bottom right cell of a table.
See Also:
Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
Aspose.Words Support Forum - our preferred method of support.