MigraDoc Two Tables in one row

cod*_*ing 4 report migradoc

I am working on creating a report with MigraDoc that would be able to have 4 tables, 2 rows with 2 tables.

I have tried a number of different methods to accomplish this.

1- I have tried creating a leftIndent on the table.

table1.Format.LeftIndent = 7;

  1. I have tried creating a leftIndent on the rows of the table.

tables.Rows.LeftIndent = 5;

  1. 我也尝试创建一个表,将每个表到一个单独的单元格,但我不知道如何放置的表格单元格中创建表的方法.

任何帮助或输入,我可以得到这将是大加赞赏.谢谢!

小智 10

这篇文章后,我能够做到这一点:

我有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");
Run Code Online (Sandbox Code Playgroud)

假设我们称那些表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);
Run Code Online (Sandbox Code Playgroud)