public class TableAlignment
extends java.lang.Object
Examples:
Shows how to apply an outline border to a table.
Document doc = new Document(getMyDir() + "Tables.docx");
Table table = doc.getFirstSection().getBody().getTables().get(0);
// Align the table to the center of the page.
table.setAlignment(TableAlignment.CENTER);
// Clear any existing borders and shading from the table.
table.clearBorders();
table.clearShading();
// Add green borders to the outline of the table.
table.setBorder(BorderType.LEFT, LineStyle.SINGLE, 1.5, Color.GREEN, true);
table.setBorder(BorderType.RIGHT, LineStyle.SINGLE, 1.5, Color.GREEN, true);
table.setBorder(BorderType.TOP, LineStyle.SINGLE, 1.5, Color.GREEN, true);
table.setBorder(BorderType.BOTTOM, LineStyle.SINGLE, 1.5, Color.GREEN, true);
// Fill the cells with a light green solid color.
table.setShading(TextureIndex.TEXTURE_SOLID, Color.GREEN, Color.GREEN);
doc.save(getArtifactsDir() + "Table.SetOutlineBorders.docx");
| Modifier and Type | Field and Description |
|---|---|
static int |
CENTER
The table is centered.
|
static int |
LEFT
The table is aligned to the left.
|
static int |
length |
static int |
RIGHT
The table is aligned to the right.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
fromName(java.lang.String tableAlignmentName) |
static java.lang.String |
getName(int tableAlignment) |
static int[] |
getValues() |
static java.lang.String |
toString(int tableAlignment) |