【发布时间】:2016-07-05 11:05:21
【问题描述】:
我尝试使用以下代码将Datagridview 中的数据导出到 PDF 文件:
LocalReport report = new LocalReport();
ReportDataSource rds1 = new ReportDataSource(dt.TableName, dt);
report.ReportPath = @"D:\Report1.rdlc";
report.DataSources.Add(rds1);
byte[] data = report.Render("PDF");
using (FileStream fs = File.Create(@"D:\output.pdf"))
{
fs.Write(data,0, data.Length);
}
数据表 'dt' 具有带值的行和列。
我没有对Report1.rdlc 做任何事。刚刚将其添加到项目中。
输出的 pdf 文件没有显示任何值。这只是一个空白页。
我在这里错过了什么?
【问题讨论】:
标签: c# datagridview pdf-generation rdlc