Free Support Forum - aspose.com

How to add text into a tablecell

Hello,

I created a dynamic table on the fly, how can I add text to a tablecell?

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.StartTable();

builder.PageSetup.Orientation = Aspose.Words.Orientation.Landscape;

builder.CellFormat.Width = 100;

for (int Count = 1; Count <= numberOfStudents; Count++)

{

for (int Count2 = 1; Count2 <= numberOfPlannedCourses; Count2++)

{

builder.InsertCell();

}

builder.EndRow();

}

builder.EndTable();

Hi

Thanks for your inquiry. Try using the following code.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.StartTable();

builder.PageSetup.Orientation = Aspose.Words.Orientation.Landscape;

builder.CellFormat.Width = 100;

for (int Count = 1; Count <= numberOfStudents; Count++)

{

for (int Count2 = 1; Count2 <= numberOfPlannedCourses; Count2++)

{

builder.InsertCell();

builder.Write("some text in cell");

}

builder.EndRow();

}

builder.EndTable();

Also see the following link
http://www.aspose.com/Products/Aspose.Words/Api/Inserting_a_Table.html

I believe that this will help you.

Best regards.