Hello!
I have added a table in a word document.
And I am trying to divide cells from a table.
I have two problems:
1.- When I divide the cell of a table line, the width of the table is not maintained. What happens when we manually divide a table into word and what seems to happen in the example I observed in the tutorial.
2.- When I divide two cells from different rows into a different number of columns, each row measures differently.
Is there any way to keep the width of the rows equal and equal to the initial size of the table?
Thank you very much for your help!
I enclose the sample code:
It is very simple.
Document spireDoc = new Document();
Section section = spireDoc.AddSection();
//add a table
Table table = section.AddTable(true);
table.ResetCells(2, 3);
//set column width
table.Rows[0].Cells[0].Width = table.Rows[0].Cells[2].Width = 50F;
table.Rows[1].Cells[0].Width = table.Rows[1].Cells[2].Width = 50F;
string resultName = String.Format(@"D:\temp\AMPO\InformesGenerados\RESULT-{0}.docx", new Random().Next(1, 100).ToString());
if (File.Exists(resultName)) File.Delete(resultName);
spireDoc.IsUpdateFields = true;
spireDoc.SaveToFile(resultName, Spire.Doc.FileFormat.Docx);
Document spireDoc2 = new Document();
Section section2 = spireDoc2.AddSection();
//add a table
Table table2 = section2.AddTable(true);
table2.ResetCells(2, 3);
//set column width
table2.Rows[0].Cells[0].Width = table.Rows[0].Cells[2].Width = 50F;
table2.Rows[1].Cells[0].Width = table.Rows[1].Cells[2].Width = 50F;
table2.Rows[0].Cells[1].SplitCell(3, 1);
table2.Rows[1].Cells[1].SplitCell(6, 1);
resultName = String.Format(@"D:\temp\AMPO\InformesGenerados\RESULT-{0}.docx", new Random().Next(1, 100).ToString());
if (File.Exists(resultName)) File.Delete(resultName);
spireDoc2.IsUpdateFields = true;
spireDoc2.SaveToFile(resultName, Spire.Doc.FileFormat.Docx);