public class TableStyleOptions
Example:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Table table = builder.startTable();
// We must insert at least one row before setting any table formatting.
builder.insertCell();
// Set the table style used based on the style identifier.
// Note that not all table styles are available when saving to .doc format.
table.setStyleIdentifier(StyleIdentifier.MEDIUM_SHADING_1_ACCENT_1);
// Partially apply the style to features of the table based on predicates, then build the table.
table.setStyleOptions(TableStyleOptions.FIRST_COLUMN | TableStyleOptions.ROW_BANDS | TableStyleOptions.FIRST_ROW);
table.autoFit(AutoFitBehavior.AUTO_FIT_TO_CONTENTS);
builder.writeln("Item");
builder.getCellFormat().setRightPadding(40.0);
builder.insertCell();
builder.writeln("Quantity (kg)");
builder.endRow();
builder.insertCell();
builder.writeln("Apples");
builder.insertCell();
builder.writeln("20");
builder.endRow();
builder.insertCell();
builder.writeln("Bananas");
builder.insertCell();
builder.writeln("40");
builder.endRow();
builder.insertCell();
builder.writeln("Carrots");
builder.insertCell();
builder.writeln("50");
builder.endRow();
doc.save(getArtifactsDir() + "DocumentBuilder.InsertTableWithStyle.docx");
Field Summary | ||
---|---|---|
static final int | NONE | |
No table style formatting is applied.
|
||
static final int | FIRST_ROW | |
Apply first row conditional formatting.
|
||
static final int | LAST_ROW | |
Apply last row conditional formatting.
|
||
static final int | FIRST_COLUMN | |
Apply 1 first column conditional formatting.
|
||
static final int | LAST_COLUMN | |
Apply last column conditional formatting.
|
||
static final int | ROW_BANDS | |
Apply row banding conditional formatting.
|
||
static final int | COLUMN_BANDS | |
Apply column banding conditional formatting.
|
||
static final int | DEFAULT_2003 | |
Row and column banding is applied. This is Microsoft Word default for old formats such as DOC, WML and RTF.
|
||
static final int | DEFAULT | |
This is Microsoft Word defaults.
|
public static final int NONE
public static final int FIRST_ROW
public static final int LAST_ROW
public static final int FIRST_COLUMN
public static final int LAST_COLUMN
public static final int ROW_BANDS
public static final int COLUMN_BANDS
public static final int DEFAULT_2003
public static final int DEFAULT