首页 > 解决方案 > 在 ITextSharp 的下一行自动创建表格

问题描述

在此处输入图像描述

例如,在此图像中,我有四个记录日期,可能在下一个 PDF 中将有 10 个记录日期然后如何设置在第一表中显示最多五个日期记录,然后在第二表中显示接下来的五个日期在 iTextSharp 中的 First-Table(第二个表自动生成)之后

 for (int c = 4; c < dt.Columns.Count; c++)
                    {
                        cell = new PdfPCell(new Phrase(dt.Columns[c].ToString(), fntMainHeading));
                        cell.Padding = 2;
                        cell.BorderColor = new Color(217, 217, 217);
                        table.AddCell(cell);

                    }
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (ServiceCode == 0 || ServiceCode != Convert.ToInt32(dt.Rows[i]["ServiceCode"]))
                    {
                        ServiceCode = Convert.ToInt32(dt.Rows[i]["ServiceCode"]);
                        cell = new PdfPCell(new Phrase(Convert.ToString(dt.Rows[i]["ServiceName"]), fntHeading));
                        cell.Padding = 2;
                        cell.Colspan = col;
                        cell.BorderColor = new Color(217, 217, 217);
                        table.AddCell(cell);
                    }
                    for (int j = 4; j < dt.Columns.Count; j++)
                    {
                        cell = new PdfPCell(new Phrase(Convert.ToString(dt.Rows[i][j]), fntNormalText));
                        cell.Padding = 2;
                        cell.BorderColor = new Color(217, 217, 217);
                        table.AddCell(cell);
                    }
                }
                table.SpacingBefore = 10;
                table.SpacingAfter = 10;
                doc.Add(table);
            }

标签: c#sqlasp.net

解决方案


推荐阅读