Inserting table cell content with carriage return using document builder

I used the document builder to create table. It works fine execept that for field with carriage return. For eg. addr 1
addr 2
addr 3

It is displayed as:
------------
name | |
------------
addr1 |tel |
------------

I released that table row height need to be adjusted so that it is high enough to fit into it.
------------
name | |
------------
addr1 |tel |
addr2 | |
addr3 | |
------------

When using mail merge method for field with carriage return, you've to hit carriage return after inserting its merge field in the template.

How can the field with carriage return be displayed completly without specifying the row height (as its height is dynamic)

Thanks,
Ben

Please make sure you use latest version of Aspose.Word as I think this was fixed some time ago. Let me know if you still have the problem after that.

Hi,

I’ve just downloaded the latest verson 1.7.5 & recompile the web application, but still having the same problem.

Also found out another issue: if the cell content is longer than the specified cell width, then the full content fails to show (it does not wrap around)

eg. for ‘company name abc d e f’

instead of showing
----------------
company name |
abc d e f |
----------------

it is truncated
----------------
company name |
----------------

The code used is something like:
while (objReader.Read ())
{
builder.RowFormat.Height = 0.18 * 72;
builder.RowFormat.HeightRule = RowHeightRule.Exactly;
foreach (Border border in builder.CellFormat.Borders)
{
border.LineStyle = LineStyle.None;
border.LineWidth = 0;
}
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
builder.Font.Size = 10;

builder.InsertCell();
builder.CellFormat.Width = 3.5 * 72;
builder.Write(objReader[COL_CoName].ToString().Trim());
builder.InsertCell();
builder.EndRow();

builder.InsertCell();
builder.CellFormat.Width = 3.5 * 72;
builder.Write(objReader[COL_Addr].ToString().Trim());
builder.InsertCell();
builder.EndRow();
}

The data source is MS SQL.


Thanks,
Ben

I tested with the demo Northwind.mdb as well. Same issues occured.

Ben

Thanks, I’ll have this investigated asap.

The contents of the cell gets truncated because you specify both explicit row height and cell widths. The cell does not grow in this case and therefore the text is truncated.

In Aspose.Word column width is always explicit (if you don't specify it will default to 1inch).

RowHeight is most often Auto (grow as needed), but also can be Exactly or AtLeast. Just stop using Exactly as row height and all should be fine.

I think the first problem you have with inserting multiple paragraphs into a table cell is the same. I double checked - I have a test that inserts this text fine. But of course the row height should not be limited using RowHeight.Exactly.

Hi Roman,

The 2 problems are resolved after removing the 'Exactly' setting.

Thanks for the helps.
Ben