MigraDoc连续两个表

时间:2015-10-14 18:13:05

标签: report migradoc

我正在使用MigraDoc创建一个报告,该报告可以有4个表,2行有2个表。

我尝试了许多不同的方法来实现这一目标。

1-我试过在桌子上创建一个leftIndent。

  

table1.Format.LeftIndent = 7;

  1. 我尝试在表格的行上创建一个leftIndent。
  2.   

    tables.Rows.LeftIndent = 5;

    1. 我还尝试创建一个表并将每个表插入一个单独的单元格,但我不知道如何放置该方法来在表格单元格中创建表格。

    2. 我将非常感谢您对此提供的任何帮助或意见。 谢谢!

2 个答案:

答案 0 :(得分:10)

关注this post我能够做到这一点:

我有4张这样的表:

        Table table = new Table();
        table.Borders.Width = 0.75;

        Column column = table.AddColumn(Unit.FromCentimeter(6));
        column.Format.Alignment = ParagraphAlignment.Left;

        Row row = table.AddRow();

        Cell cell = row.Cells[0];
        cell.AddParagraph("some value on first row");

        row = table.AddRow();
        cell = row.Cells[0];
        cell.AddParagraph("another value on second row");

        row = table.AddRow();
        cell = row.Cells[0];
        cell.AddParagraph("The value on third row");

假设我们称那些表为table,table2,table3和table4。

我们可以在MigraDoc上的一行单元格中插入一个表格,如下所示:

        Document document = new Document();
        Table TableContainer = new Table();
        Column columnC = TableContainer.AddColumn(Unit.FromCentimeter(7));
        TableContainer.AddColumn(Unit.FromCentimeter(7));

        Row rowC = TableContainer.AddRow();
        Cell cellC = rowC.Cells[0];
        cellC.AddParagraph("First Column");
        cellC = rowC.Cells[1];
        cellC.AddParagraph("Second Column");

        rowC = TableContainer.AddRow();
        cellC = rowC.Cells[0];
        cellC.Elements.Add(table);
        cellC = rowC.Cells[1];
        cellC.Elements.Add(table2);

        rowC = TableContainer.AddRow();
        cellC = rowC.Cells[0];
        cellC.Elements.Add(table3);
        cellC = rowC.Cells[1];
        cellC.Elements.Add(table4);

        document.LastSection.Add(TableContainer);

答案 1 :(得分:0)

我没有看到任何问题。 ; - )

回复3:向表中添加表有一个已知的技巧:向Cell添加TextFrame并将Table添加到TextFrame。

单元格无法分解到下一页,因此内部表格必须足够小以适合一页。