We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Table Cell Widths - Unsure of How to Proceed

Below you’ll see the code I’m using to generate a table. I cannot seem to get a handle on the cell widths. I’ve tried to set them to varying widths, but for the most part, they seem to remain the same width.

Document doc = new Document(Environment.CurrentDirectory + "\\TestGift.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToMergeField("PoliciesList");
// Start table
Table myTab = builder.StartTable();
builder.Font.Bold = true;
builder.RowFormat.HeadingFormat = true;
builder.RowFormat.Height = 13;
builder.RowFormat.HeightRule = HeightRule.Exactly;
builder.RowFormat.Borders.LineStyle = LineStyle.Single;
builder.RowFormat.Borders.LineWidth = 1.0;
builder.CellFormat.WrapText = false;
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
// Write headers
Cell carrierCell = builder.InsertCell();
builder.Write("Carrier");
carrierCell.CellFormat.Width = 100;
builder.InsertCell();
builder.Write("Policy No.");
builder.InsertCell();
builder.Write("Premium Mode");
builder.InsertCell();
builder.Write("Grantor Pays");
builder.EndRow();
builder.RowFormat.HeadingFormat = false;
builder.Font.Bold = false;
builder.CellFormat.WrapText = true;
for (int i = 0; i < 10; i++)
{
    builder.InsertCell();
    builder.Write("Carrier_" + i.ToString());
    builder.InsertCell();
    builder.Write(i.ToString());
    builder.InsertCell();
    builder.Write("Mode_" + i.ToString());
    builder.InsertCell();
    builder.Write("Payment_" + i.ToString());
    builder.EndRow();
}
builder.EndTable();
doc.Save(Guid.NewGuid().ToString() + ".doc");

Hi
Thanks for your inquiry. This is the same issue as described in the following forum thread.
Code examples there are provided in Java but I think you can easy translate code in C#.
Best regards.