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

Free Support Forum - aspose.com

How to add column and rows to aspose.words table

Hi,

  1. I have a html file which has tables on it, tables are html calendars,
  2. I am getting those table and looping to each cell for me to be able to insert form fields and text to it.

Question:
How can add 1 column to rightmost of each calendar table and 1 row at the bottom and insert form fields also to it?

Hi there,

Thanks for sharing the detail. Please note that a table in MS Word is a set of independent rows. Each row has a set
of cells independent on cells of other rows. So there is no logical
“column” in a MS Word’s table. “The 1st column” is something like “a set
of the 1st cells of each row in a table”.
For example, it’s possible to have a table where the 1st row consists
of two cells: 2cm and 1cm and the 2nd row consists of different two
cells: 1cm and 2cm of width.
However, you can work with columns using the approach shared at following documentation link.[
https://docs.aspose.com/words/net/working-with-columns-and-rows/
Please use the following code example to insert row at the end of table and insert a text input form field. Please let us know if you have any more queries.

var doc = new Document(MyDir + "in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
// Get the first table in the document
Table table = doc.FirstSection.Body.Tables[0];
// insert empty row at the end of table
Row lastrow = (Row)table.LastRow.Clone(true);
table.AppendChild(lastrow);
foreach (Cell cell in lastrow.Cells)
{
    cell.RemoveAllChildren();
    cell.EnsureMinimum();
    cell.CellFormat.ClearFormatting();
    builder.MoveTo(cell.FirstChild);
    builder.InsertTextInput("TextInput", TextFormFieldType.Regular, "", "Hello", 0);
}
doc.Save(MyDir + "Out.docx");