TableStyleOptions

Inheritance: java.lang.Object

public class TableStyleOptions

Specifies how table style is applied to a table.

Examples:

Shows how to build a new table while applying a style.


 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");
 

Fields

FieldDescription
COLUMN_BANDSApply column banding conditional formatting.
DEFAULTThis is Microsoft Word defaults.
DEFAULT_2003Row and column banding is applied.
FIRST_COLUMNApply 1 first column conditional formatting.
FIRST_ROWApply first row conditional formatting.
LAST_COLUMNApply last column conditional formatting.
LAST_ROWApply last row conditional formatting.
NONENo table style formatting is applied.
ROW_BANDSApply row banding conditional formatting.
length

Methods

MethodDescription
fromName(String tableStyleOptionsName)
fromNames(Set tableStyleOptionsNames)
getName(int tableStyleOptions)
getNames(int tableStyleOptions)
getValues()
toString(int tableStyleOptions)
toStringSet(int attr)

COLUMN_BANDS

public static int COLUMN_BANDS

Apply column banding conditional formatting.

DEFAULT

public static int DEFAULT

This is Microsoft Word defaults.

DEFAULT_2003

public static int DEFAULT_2003

Row and column banding is applied. This is Microsoft Word default for old formats such as DOC, WML and RTF.

FIRST_COLUMN

public static int FIRST_COLUMN

Apply 1 first column conditional formatting.

FIRST_ROW

public static int FIRST_ROW

Apply first row conditional formatting.

LAST_COLUMN

public static int LAST_COLUMN

Apply last column conditional formatting.

LAST_ROW

public static int LAST_ROW

Apply last row conditional formatting.

NONE

public static int NONE

No table style formatting is applied.

ROW_BANDS

public static int ROW_BANDS

Apply row banding conditional formatting.

length

public static int length

fromName(String tableStyleOptionsName)

public static int fromName(String tableStyleOptionsName)

Parameters:

ParameterTypeDescription
tableStyleOptionsNamejava.lang.String

Returns: int

fromNames(Set tableStyleOptionsNames)

public static int fromNames(Set tableStyleOptionsNames)

Parameters:

ParameterTypeDescription
tableStyleOptionsNamesjava.util.Set

Returns: int

getName(int tableStyleOptions)

public static String getName(int tableStyleOptions)

Parameters:

ParameterTypeDescription
tableStyleOptionsint

Returns: java.lang.String

getNames(int tableStyleOptions)

public static Set getNames(int tableStyleOptions)

Parameters:

ParameterTypeDescription
tableStyleOptionsint

Returns: java.util.Set

getValues()

public static int[] getValues()

Returns: int[]

toString(int tableStyleOptions)

public static String toString(int tableStyleOptions)

Parameters:

ParameterTypeDescription
tableStyleOptionsint

Returns: java.lang.String

toStringSet(int attr)

public static String toStringSet(int attr)

Parameters:

ParameterTypeDescription
attrint

Returns: java.lang.String