PDFsharp & MigraDoc Foundation http://forum.pdfsharp.de/ |
|
Table Information for each record ending up in the Header! http://forum.pdfsharp.de/viewtopic.php?f=2&t=4160 |
Page 1 of 1 |
Author: | -Mirage- [ Thu Jul 30, 2020 6:19 pm ] | ||
Post subject: | Table Information for each record ending up in the Header! | ||
Hi, so trying to render a PDF that includes a Table. Here is the Header of the Table, no issue with this: Code: // def header of table MigraDoc.DocumentObjectModel.Tables.Row row = table.AddRow(); MigraDoc.DocumentObjectModel.Tables.Cell cell = row.Cells[0]; cell.AddParagraph("Jurisdictions"); cell.Format.Font.Bold = true; cell = row.Cells[1]; cell.AddParagraph("Approval#"); cell.Format.Font.Bold = true; cell = row.Cells[2]; cell.AddParagraph("Notes"); cell.Format.Font.Bold = true; cell = row.Cells[3]; cell.AddParagraph("Jurisdiction Fee"); cell.Format.Font.Bold = true; cell = row.Cells[4]; cell.AddParagraph("Permit Now Fee"); cell.Format.Font.Bold = true; The problem is when I try and insert (from a database the values stored therein). Here is the code loading the data and attempting to display it: Code: connection = new MySqlConnection(connetionString); connection.Open(); command = new MySqlCommand(sql, connection); adapter.SelectCommand = command; // adapter.Fill(ds); adapter.Fill(dt); connection.Close(); foreach(DataRow newrow in dt.Rows) { row.Table.AddRow(); cell = row.Cells[0]; cell.AddParagraph(newrow["ApprovalJurisdiction"].ToString()); cell = row.Cells[1]; cell.AddParagraph(newrow["ApprovalAppNumber"].ToString()); cell = row.Cells[2]; cell.AddParagraph(newrow["ApprovalNotes"].ToString()); cell = row.Cells[3]; cell.AddParagraph(newrow["ApprovalJurisdictionFee"].ToString()); cell = row.Cells[4]; cell.AddParagraph(newrow["ApprovalPermitNowFee"].ToString()); } I've attached a copy of the output. It literally puts everything in the right column, but all in the header. I had a FOR loop populating this table, but someone said use a FOR EACH loop, but the output is the same. Any assistance would be appreciated! G
|
Author: | TH-Soft [ Thu Jul 30, 2020 7:30 pm ] |
Post subject: | Re: Table Information for each record ending up in the Heade |
-Mirage- wrote: row.Table.AddRow(); This code adds a new row to the table and returns it. However the return value is not used and you continue to add elements to the first row.Something like "row = row.Table.AddRow();" would make a big difference. |
Author: | -Mirage- [ Thu Jul 30, 2020 9:40 pm ] |
Post subject: | Re: Table Information for each record ending up in the Heade |
Hi TH-Soft, Thank you for the quick reply! I've changed my code and it worked, awesome! |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |