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;
tables.Rows.LeftIndent = 5;
Any help or input that I can get on this would be much appreciated. Thank you!
Following this post I was able to achieve this:
I had 4 tables like this:
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");
Let's say we call those tables table, table2, table3 and table4.
We can insert a table inside a cell of a row on MigraDoc like this:
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With