c# - 在 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);
}
解决方案
推荐阅读
- javascript - Rollup - 没有使用带有 Babel 的 Typescript 进行 treeshaking
- javascript - 如果自定义模式 100% 匹配,则 Javascript 正则表达式返回 true
- http - 如何解码服务器对 utf-8 的响应?
- angularjs - angularJS 自定义 chrome devtools 网络
- javascript - 时间/空间复杂性 - 如何计算这个函数?
- c# - 这是对带有重复项的 SortedList 的合理使用吗
- sql - 在组队或第二次加入工作时遇到问题
- python - WebDriverException: /usr/bin/safaridriver 在 CircleCI 容器中运行时意外退出错误
- javascript - 单击锚点时显示引导警报消息框
- apache - 通过虚拟主机 (Apache) 设置 Wiki 场