Free Support Forum - aspose.com

Table Cell split

Hi,

Is it possible to create a table cell as mentioned in the attached document?

Thanks,
Ashish.

@ASHPose,

Thanks for your inquiry. Yes, you can create the desired table using Aspose.Words.

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.

We suggest you please read the following article.
Specifying Table and Cell Widths

Please check the following code example. Hope this helps you.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Table table = builder.StartTable();

// Insert a cell
Cell cell1 = builder.InsertCell();
cell1.CellFormat.Width = 120; 

// Insert a cell
builder.InsertCell();
builder.CellFormat.Width = 135;

builder.EndRow();

builder.InsertCell();
builder.CellFormat.Width = 135;

// Insert a cell
builder.InsertCell();
builder.CellFormat.Width = 120;

builder.EndRow();

builder.EndTable();

doc.Save(MyDir + "18.4.docx");

Thanks.

Can the same be achieved using DOM objects i.e. Table, Row & Cell?

@ASHPose,

Thanks for your inquiry. Yes, you can create the table using DOM objects. Please refer to the following article.
Inserting a Table Directly into the Document Object Model

Please use Cell.CellFormat.Width property to set the width of cell. Hope this helps you.