嘗試下面的例子,它在我結束最新發布的工作。 第一個表格是在文檔中創建的。 第二個表格是在第一個表格的單元格內創建的。
Aspose.Words.Document doc = new Aspose.Words.Document();
// Create first table with 1 row and 2 columns
Aspose.Words.Tables.Table table = new Aspose.Words.Tables.Table(doc);
// Add the table to the document.
doc.FirstSection.Body.AppendChild(table);
Aspose.Words.Tables.Row row = new Aspose.Words.Tables.Row(doc);
table.AppendChild(row);
Aspose.Words.Tables.Cell cell1 = new Aspose.Words.Tables.Cell(doc);
row.AppendChild(cell1);
Aspose.Words.Tables.Cell cell2 = new Aspose.Words.Tables.Cell(doc);
row.AppendChild(cell2);
table.SetBorders(LineStyle.Dot, 1, System.Drawing.Color.Red);
// Add the second table in cell1
Aspose.Words.Tables.Table table2 = new Aspose.Words.Tables.Table(doc);
cell1.AppendChild(table2);
Aspose.Words.Tables.Row row2 = new Aspose.Words.Tables.Row(doc);
table2.AppendChild(row2);
Aspose.Words.Tables.Cell cell3 = new Aspose.Words.Tables.Cell(doc);
row2.AppendChild(cell3);
Aspose.Words.Tables.Cell cell4 = new Aspose.Words.Tables.Cell(doc);
row2.AppendChild(cell4);
table2.SetBorders(LineStyle.DotDash, 1, System.Drawing.Color.Blue);
輸出文檔看起來像
[閱讀Aspose嵌套表格]的可能的複製(http://stackoverflow.com/q/15222963/2596334)。 – 2014-11-04 20:27:26
@Okuma ...我不認爲這是重複的。我正在使用Aspose.Words.Tables.Table對象而不是DataSet對象。我在Aspose Table上看不到一個Relation對象。感謝您的建議,壽 – MikeTWebb 2014-11-04 20:42:25