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

Free Support Forum - aspose.com

Table column widths not sticking

I have the following code to generate a simple 2 column table. I set the first column to be 6.5" wide and the second column to be 1" wide. However, when I run the code, I get a table where both columns are 1" wide. I am a new user of this component, and I know I must be missing something very basic.

Can anyone help?

Thanks!

Scott

Paragraph p = new Paragraph(doc);
doc.FirstSection.Body.AppendChild§;
builder.MoveTo(doc.FirstSection.Body.LastParagraph);

builder.Font.Size = 10;
builder.Font.Name = "Futura Lt";

BorderCollection borders = builder.CellFormat.Borders;
borders.LineStyle = LineStyle.None;

for (int i = 1; i <= 5; i++)
{
    builder.CellFormat.Width = 6.5 * 72; // 6.5"
    builder.InsertCell();
    builder.Write("This is the text in the first column");

    builder.CellFormat.Width = 1.0 * 72; // 1.0"
    builder.InsertCell();
    builder.Write("This is the text in the second column");

    builder.EndRow();
}
builder.EndTable();

Hi
Thanks for your inquiry. Please try using the following code:

builder.MoveTo(doc.FirstSection.Body.LastParagraph);
builder.Font.Size = 10;
builder.Font.Name = "Futura Lt";
BorderCollection borders = builder.CellFormat.Borders;
borders.LineStyle = LineStyle.None;
for (int i = 1; i <= 5; i++)
{
    builder.InsertCell();
    builder.CellFormat.Width = ConvertUtil.InchToPoint(6.5);// 6.5"
    builder.Write("This is the text in the first column");
    builder.InsertCell();
    builder.CellFormat.Width = ConvertUtil.InchToPoint(1.0); // 1.0"
    builder.Write("This is the text in the second column");
    builder.EndRow();
}
builder.EndTable();

Best regards.

Hi Alexey,

Woohoo!! That worked. Thanks a lot for your quick reply and help on this.

Scott