我最近为 asp.net 安装了 DocX,并且遇到了为未知数量的行创建循环的问题。
我正在为来自 SQL 服务器的用户创建报告。其中一部分与历史有关,在每个报告的数据库中,创建的每个报告都有不同数量的行。有没有办法创建一个循环或类似的方法来输出这个未知数量的行?
for (int i = 0; i <= 2; i++)
{
t.Rows[i].Cells[0].Paragraphs.First().Append(Data from SQL);
}
t.Alignment = Alignment.center;
t.Design = TableDesign.TableGrid;
t.Rows[0].Cells[0].Paragraphs.First().Append("Update Date");
t.Rows[0].Cells[1].Paragraphs.First().Append("Update By");
t.Rows[0].Cells[2].Paragraphs.First().Append("Code");
t.Rows[0].Cells[3].Paragraphs.First().Append("Status/Description");
t.Rows[0].Cells[4].Paragraphs.First().Append("System");
t.Rows[1].Cells[0].Paragraphs.First().Append("update_date");
t.Rows[1].Cells[1].Paragraphs.First().Append("update_by");
t.Rows[1].Cells[2].Paragraphs.First().Append("codes");
t.Rows[1].Cells[3].Paragraphs.First().Append("status");
t.Rows[1].Cells[4].Paragraphs.First().Append("system");
t.rows[0].Cells[0-4]
是标题,其余的将来自数据库。有没有比使用 DocX 更好的方法?
t.Rows[1].Cells[0-4]
需要来自数据库(SQL 中的表头)这让我很沮丧,我从来都不擅长循环
感谢您的时间。