Free Support Forum - aspose.com

Cannot insert table into a word document correctly

Hi - Can you please take a look at this and let me know why it's not working. I am trying to add the data at the point marked (I WANT TO MAKE THIS INTO A TABLE) as a table but Aspose cannot do it. It creates the table with nonsensible format. A prompt response is much appreciated as I need to get this done by end of today

I use the following code

builder.MoveToBookmark(aComment);

builder.StartTable();

builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;

foreach(System.Data.DataRow aRow in resultTable.Rows){

for(int j=0;j < resultTable.Columns.Count; j++){

builder.CellFormat.WrapText = false;

builder.CellFormat.FitText = false;

builder.Font.Size = 8;

builder.InsertCell();

string aCell = DSPSystem.CommonClasses.StandardLib.ToTitleCase(aRow[j].ToString());

builder.Write(aCell);

}

builder.EndRow();

}

builder.EndTable();

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Please try using the following code and let me know if this helps.

builder.MoveToBookmark("DSPSystemTop10Holdings", false, true);

builder.CellFormat.ClearFormatting();

builder.RowFormat.LeftIndent = builder.ParagraphFormat.LeftIndent;

builder.ParagraphFormat.ClearFormatting();

builder.StartTable();

builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;

foreach (System.Data.DataRow aRow in resultTable.Rows)

{

for (int j = 0; j < resultTable.Columns.Count; j++)

{

builder.CellFormat.WrapText = false;

builder.CellFormat.FitText = false;

builder.Font.Size = 8;

builder.InsertCell();

string aCell = aRow[j].ToString();

builder.Write(aCell);

}

builder.EndRow();

}

builder.EndTable();

Best regards.

That works fine. Thank you