Controlling Tables


#1

Hi

I am having trouble controlling tables. How can i?

a) control row height either by use of height or cell spacing/padding. I have tried using RowFormat.Height = 5; but it has not worked for me.

b) control cell backcolor etc

I find my tables look very padded and too big (tall) for the data.

here is my code… thx

protected void writeCell(string text, double width, bool isheading) {
if (isheading) {
// set font style
this.setFontTableHeading();
} else {
this.setFontTableContent();
}
this.aspDocBuilder.InsertCell();
this.aspDocBuilder.CellFormat.Width = width;
this.aspDocBuilder.Writeln(text);
}

this.aspDocBuilder.StartTable();
this.aspDocBuilder.RowFormat.Height = 5;
this.writeCell(“Text”, 45, true);
this.writeCell(“Sfffort Group”, 100, true);
this.writeCell(“ProDdd”, 60, true);
this.writeCell(“Prodd”, 60, true);
this.writeCell(“PrDdity”, 50, true);
this.writeCell(“Suppdddff”, 80, true);
this.writeCell(“Calls”, 30, true);
this.writeCell("%", 25, true);
this.aspDocBuilder.EndRow();
this.aspDocBuilder.EndTable();


#2

Hi,

1. You are right, row height is controlled by RowFormat.Height, but in conjunction with RowFormat.HeightRule that is responsible for setting a rule determining the height of the row.

2. To learn how to set cell background color see the Shading class (returned by CellFormat.Shading) and an example at

http://www.aspose.com/forums/ShowPost.aspx?PostID=17729.


#3

Thanks for the information… I have applied the exactly rule:

this.aspDocBuilder.StartTable();

this.aspDocBuilder.RowFormat.Height = 15;

this.aspDocBuilder.RowFormat.HeightRule = RowHeightRule.Exactly;

but am still not happy with the result… see the attached document. There is way too much space above the text and hence the text is truncated. For me to fit all text in I would have to make the height 25 and that is too big. If this was html it would look like the cell padding was excessive. Is there not a way to control this so the space above and below the text can be minimised?

Thanks

#4

This result is a normal behaviour because description of RowHeightRule.Exactly says that "Please note that if the text cannot fit inside the cell of this height, it will appear truncated."

Try to align the text using CellFormat.VerticalAlignment.