[英]Exporting a Chart into RDLC report
我有一个页面,客户端上有一个图表。 现在,需要将此图表放入RDLC报告中。 我已经在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();
我建议以下。
通过传递用于在该页面上绘制图表的相同内容,为该图表创建RDLC报告。 这种方法对您确实很有帮助,您可以根据客户要求对其进行修改。
您可以将图像设置为RDLC。 使用RDLC图像控件。 将图像完整路径传递到将在RDLC报告中使用的数据集。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.