Free Support Forum - aspose.com

Setting row height of table in aspose.word

hi.

i created a table in aspose.word using :

builder.Font.Size = 12;
builder.Font.Name = “Arial”;
builder.RowFormat.Height = 23;
builder.CellFormat.Width = 250;
builder.InsertParagraph();

i want to make the height of the rows bigger, but where-ever i set the rowformat.height, it doesn’t changes anything…

anybody??

You need to specify row height before creating the table row and you might need to specify HeightRule for the rule. The example below works to create cells .75" height exactly.

///

/// Creates a chess like table to test borders and shading.

///

[Test]

public void TestChess()

{

builder.Font.Size = 8;

builder.Font.Name = “Tahoma”;

builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;

builder.RowFormat.Height = 0.75 * 72;

builder.RowFormat.HeightRule = RowHeightRule.Exactly;

builder.CellFormat.Width = 0.75 * 72;

builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;

foreach (Border border in builder.CellFormat.Borders)

{

border.LineStyle = LineStyle.Single;

border.LineWidth = 2;

border.Color = System.Drawing.Color.Blue;

}

for (int y = 0; y < 8; y++)

{

for (int x = 0; x < 8; x++)

{

builder.InsertCell();

builder.Write(string.Format(“X{0}, Y{1}”, x, y));

bool isBlack = (((x + y) & 0x01) != 0);

builder.CellFormat.Shading.BackgroundPatternColor =

(isBlack) ? System.Drawing.Color.LightGreen : System.Drawing.Color.LightYellow;

}

builder.EndRow();

}

builder.EndTable();

builder.ParagraphFormat.ClearFormatting();

builder.ParagraphFormat.KeepWithNext = true;

builder.ParagraphFormat.SpaceAfter = 12;

builder.ParagraphFormat.SpaceBefore = 11;

builder.Font.Name = “Arial”;

builder.Font.Bold = true;

builder.Font.Underline = Underline.Thick;

builder.Font.Size = 12;

builder.Writeln(“blah blah”);

SaveOpen();

}