0
我想用row-span屬性打印使用流文檔的表。表Rowspan問題flowdocument C#
我想打印以下輸出,
,但它給了我這個
我不明白這有什麼錯我的代碼,也許我錯過了一些東西。 任何幫助appreciated.Please看到下面的代碼,
Table tbl = new Table();
for (int i = 0; i < 2; i++)
{
TableColumn tableCol = new TableColumn();
tableCol.Width = new GridLength(150);
tbl.Columns.Add(tableCol);
}
TableRow row = new TableRow();
row.Background = Brushes.White;
row.FontSize = PointsToPixels(TITLETEXTSIZE);
row.FontFamily = new FontFamily(FONTFAMILY);
row.Cells.Add(new TableCell(new Paragraph(new Run("cell1"))));
row.Cells[0].BorderBrush = Brushes.Black;
row.Cells[0].BorderThickness = new Thickness(0.0, 1.0, 1, 0.0);
row.Cells[0].RowSpan = 2;
row.Cells.Add(new TableCell(new Paragraph(new Run("cell2"))));
row.Cells[1].BorderBrush = Brushes.Black;
row.Cells[1].BorderThickness = new Thickness(0.0, 0.0, 0, 1.0);
row.Cells[1].RowSpan = 1;
var rowgroup = new TableRowGroup();
rowgroup.Rows.Add(row);
tbl.RowGroups.Add(rowgroup);
row = new TableRow();
row.Background = Brushes.White;
row.FontSize = PointsToPixels(TITLETEXTSIZE);
row.FontFamily = new FontFamily(FONTFAMILY);
row.Cells.Add(new TableCell(new Paragraph(new Run("cell1"))));
row.Cells[0].BorderBrush = Brushes.Black;
row.Cells[0].BorderThickness = new Thickness(0.0, 1.0, 1, 1.0);
row.Cells[0].RowSpan = 1;
rowgroup = new TableRowGroup();
rowgroup.Rows.Add(row);
tbl.RowGroups.Add(rowgroup);
tbl.BorderThickness = new Thickness(1, 1, 1, 0);
tbl.BorderBrush = Brushes.Black;
得到了答案的想法。而不是創建新的TableRowGroup,** rowgroup = new TableRowGroup(); **我向現有的行組添加了新行。 – sharad