2016-04-25 56 views
0

我正在MigraDoc中建立一個表格。我找到了一種方法,在TextFrame的幫助下將Table放入Table.Row.Cell。不幸的是,當向TextFrame添加新條目時,Row.Cell不會增長。所以在某個時候,內表與下面的行重疊。MigraDoc:如何在添加文本時擴展行高?

這裏是我的代碼:

this.Table = this.MigraDokument.AddSection().addTable(); 
Row row = this.Table.AddRow(); 
TextFrame Frame = row.Cells[0].AddTextFrame(); 

Table k_table = Frame.AddTable(); 
// adding rows with 
// Row row2 = k_table.AddRow(); 

我怎麼能告訴Row.Cell與我放到表內的每個條目成長?

編輯:我的問題不是我不能添加嵌套表,如[MigraDoc - imbricated/nested tables?。 雖然鏈接的答案幫助了我。 這個問題處理的主題是TextFrames可能不適合在表格中嵌套表格,因爲單元格不能用嵌套表格進行縮放。

+0

可能重複的[MigraDoc - 鱗狀/嵌套表?](http://stackoverflow.com/questions/36303719/migradoc-imbricated-nested-tables) –

+0

這是一種可能的dublicate在某種程度上,雖然我的問題本身與Link中的有點不同。但Link的解決方案/黑客幫助。看我的答案。謝謝PDFsharp團隊 –

+0

不是同一個問題,但同樣的問題 - 同樣的解決方案適用於這兩個問題。如果他們只是有點不同,我們是否需要他們? –

回答

0

來自[MigraDoc - imbricated/nested tables?的未公開的功能是答案: 現在代碼看起來這樣,它工作正常。

this.Table = this.MigraDokument.AddSection().addTable(); 
Row row = this.Table.AddRow(); 
// Here I grab the cell that I want to populate later 
Cell dataCell = row.Cells[0]; 

// Than I build the table with alle the necessary Information in it 
Table k_table = new Table(); 
// adding columns and rows with 
k_table.AddColumn(); 
k_table.AddColumn(); 
Row row = k_table.AddRow(); 
// and populate with data 
row.Cells[0].AddParagraph("Stuff 1"); 
row.Cells[1].AddParagraph("Stuff 2"); 

// The final trick is to add it in the end to the `Elements` 
// property of the cell 
dataCell.Elements.add(k_table); 

的最後一步具有將表-細胞已成長爲 延伸,即嵌套表得到的效果! 不需要合併下面的額外行。 這個方法似乎比使用TextFrame更靈活,因爲我在我的問題中嘗試了 。

相關問題