com.aspose.words

Class CellVerticalAlignment

  • java.lang.Object
    • com.aspose.words.CellVerticalAlignment
public class CellVerticalAlignment 
extends java.lang.Object

Utility class containing constants. Specifies vertical justification of text inside a table cell.

Example:

Shows how to build a formatted 2x2 table.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Table table = builder.startTable();
builder.insertCell();
builder.getCellFormat().setVerticalAlignment(CellVerticalAlignment.CENTER);
builder.write("Row 1, cell 1.");
builder.insertCell();
builder.write("Row 1, cell 2.");
builder.endRow();

// While building the table, the document builder will apply its current RowFormat/CellFormat attribute values
// to the current row/cell that its cursor is in and any new rows/cells as it creates them.
Assert.assertEquals(CellVerticalAlignment.CENTER, table.getRows().get(0).getCells().get(0).getCellFormat().getVerticalAlignment());
Assert.assertEquals(CellVerticalAlignment.CENTER, table.getRows().get(0).getCells().get(1).getCellFormat().getVerticalAlignment());

builder.insertCell();
builder.getRowFormat().setHeight(100.0);
builder.getRowFormat().setHeightRule(HeightRule.EXACTLY);
builder.getCellFormat().setOrientation(TextOrientation.UPWARD);
builder.write("Row 2, cell 1.");
builder.insertCell();
builder.getCellFormat().setOrientation(TextOrientation.DOWNWARD);
builder.write("Row 2, cell 2.");
builder.endRow();
builder.endTable();

// Previously added rows and cells are not retroactively affected by changes to the builder's formatting.
Assert.assertEquals(0.0, table.getRows().get(0).getRowFormat().getHeight());
Assert.assertEquals(HeightRule.AUTO, table.getRows().get(0).getRowFormat().getHeightRule());
Assert.assertEquals(100.0, table.getRows().get(1).getRowFormat().getHeight());
Assert.assertEquals(HeightRule.EXACTLY, table.getRows().get(1).getRowFormat().getHeightRule());
Assert.assertEquals(TextOrientation.UPWARD, table.getRows().get(1).getCells().get(0).getCellFormat().getOrientation());
Assert.assertEquals(TextOrientation.DOWNWARD, table.getRows().get(1).getCells().get(1).getCellFormat().getOrientation());

doc.save(getArtifactsDir() + "DocumentBuilder.BuildTable.docx");

Field Summary
static final intTOP = 0
Text is aligned at the top of a cell.
static final intCENTER = 1
Text is aligned in the middle of a cell.
static final intBOTTOM = 2
Text is aligned at the bottom of the cell.
 

    • Field Detail

      • TOP = 0

        public static final int TOP
        Text is aligned at the top of a cell.
      • CENTER = 1

        public static final int CENTER
        Text is aligned in the middle of a cell.
      • BOTTOM = 2

        public static final int BOTTOM
        Text is aligned at the bottom of the cell.