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

Free Support Forum - aspose.com

Inner table with general title

I have table like this

first

second

third<o:p></o:p>



How can i do this table , with 2-level hierarchy or more /

<span style=“font-size:10.0pt;font-family:“Times New Roman”,“serif”;
mso-fareast-font-family:“Times New Roman”;mso-ansi-language:RU;mso-fareast-language:
RU;mso-bidi-language:AR-SA;mso-no-proof:yes”>

header

first

second

third

. I have one idea : MoveTo current Cell ,Add New Cell , and add this lower cells(first,second,third ) and header cell (header) in this. This is what i want to result.

Hi Ilya,


Thanks for your inquiry. Please see attached sample input/output Word documents and following code to achieve this requirement.

Document doc = new Document(MyDir + @“in.docx”);

Table tab = (Table)doc.GetChildNodes(NodeType.Table, true)[0];<o:p></o:p>

Row clone = (Row) tab.FirstRow.Clone(true);

tab.Rows.Add(clone);

foreach (Cell cell in tab.FirstRow)

{

cell.RemoveAllChildren();

if (cell.IsFirstCell)

{

cell.CellFormat.HorizontalMerge = CellMerge.First;

cell.Paragraphs.Add(new Paragraph(doc));

cell.FirstParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Center;

cell.FirstParagraph.Runs.Add(new Run(doc, "header"));

}

else

{

cell.CellFormat.HorizontalMerge = CellMerge.Previous;

}

}

doc.Save(MyDir + @"15.8.0.doc");

Hope, this helps.

Best regards,