Free Support Forum - aspose.com

Table columns are appearing too close to each other when doc is saved as an .htm file

Hi,

I am using Aspose.Word to create word document.

I am adding table to the document and populating data into it.

When i open word document spacing betwn columns is (i am using default) is preserved and everything looks good.

But when I save word document as an .htm and when I open .htm file, colums appear too close to each other with almost no psacing between them

Please can you advise how I can get the HTML document to have table cells properly spaced from each other.

Below is the code which I am using to create the table:

// Start Table

builder.StartTable();

builder.RowFormat.ClearFormatting();

builder.CellFormat.ClearFormatting();

builder.RowFormat.HeadingFormat = oHeadingRow;

builder.RowFormat.Alignment = RowAlignment.Left;

// Create Table Headers first

string coldata;

string[] tableheader = (string[])columns[0];

for (int i = 0; i < tableheader.Length; i++)

{

coldata = tableheader[i].TrimStart(new char[] { '\n' });

builder.InsertCell();

builder.Write(coldata);

}

builder.EndRow();

// Create data Rows

for (int i = 1; i < columns.Length; i++)

{

string[] rowdata = (string[])columns[i];

for (int j = 0; j < rowdata.Length; j++)

{

coldata = rowdata[j].TrimStart(new char[] { '\n' });

builder.InsertCell();

builder.Write(coldata);

}

builder.EndRow();

}

// End Table

builder.EndTable();

Thanks

Hi

Thanks for your request. I think that you should hardcode width of the cell. For example

builder.CellFormat.Width = 100;

Hope this helps.

Best regards.