C# 将图表导出到RDLC报告中
我有一个客户有图表的页面。现在需要将此图表放入RDLC报告中。C# 将图表导出到RDLC报告中,c#,asp.net,rdlc,C#,Asp.net,Rdlc,我有一个客户有图表的页面。现在需要将此图表放入RDLC报告中。 我已在System.Drawing.image中收集了图表的图像,但不知道如何将其放入RDLC。我将图像绑定到其中一列,然后将其绑定到数据集,以将图像提取到RDLC报告中。 这是代码 DataTable dt = new DataTable(); DataColumn column = new DataColumn("chart"); column.DataType = System.Type.Get
我已在System.Drawing.image中收集了图表的图像,但不知道如何将其放入RDLC。我将图像绑定到其中一列,然后将其绑定到数据集,以将图像提取到RDLC报告中。 这是代码
DataTable dt = new DataTable();
DataColumn column = new DataColumn("chart");
column.DataType = System.Type.GetType("System.Byte[]");
dt.Columns.Add(column);
DataRow dr = dt.NewRow();
//Saving the Image of Graph into memory stream
System.IO.MemoryStream ms = new System.IO.MemoryStream();
Chart1.SaveImage(ms, ChartImageFormat.Png);
byte[] ByteImage = new byte[ms.Length];
ms.Position = 0;
ms.Read(ByteImage, 0, (int)ms.Length);
dr["chart"] = ByteImage;
string s = dr[0].ToString();
dt.Rows.Add(dr);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.ReportPath = "Report1.rdlc";
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1",dt));
ReportViewer1.Visible = true;
ReportViewer1.LocalReport.Refresh();
我建议如下
您正在尝试向报表中添加静态图像吗?或者您正在尝试在运行时以编程方式向报表中添加图像?是的,我想添加图像,但我用了其他方法。你能分享一下你能做到的方法吗(作为答案)?