将picturebox中的图像分配给rdlc报告
本文关键字:rdlc 报告 分配 图像 picturebox | 更新日期: 2023-09-27 18:21:24
我想知道是否可以将gui中的图片框中的图片添加到rdlc报告中。现在我对所有的字符串都这样做,但我也想添加一张图片。
reportViewer3.Visible=true;
DataSet2 DsActivityReport = new DataSet2();
ReportDataSource reportDataSource = new ReportDataSource();
reportDataSource.Name = "DataSet1";
reportDataSource.Value = DsActivityReport.Tables[0];
ReportParameter name = new ReportParameter("NAME", txtNAME.Text);
ReportParameter employee_id = new ReportParameter("EMPLOYEE_ID", txtEmpNo.Text);
ReportParameter company_id = new ReportParameter("COMPANY_ID", txtCompany.Text);
ReportParameter emp_no = new ReportParameter("EMP_NO", txtEmpNo.Text);
//ReportParameter emp_picture = new ReportParameter("picture", );
reportViewer3.LocalReport.EnableExternalImages = true;
reportViewer3.LocalReport.DataSources.Clear();
reportViewer3.LocalReport.SetParameters(new ReportParameter[] { name, employee_id, company_id, emp_no});
reportViewer3.LocalReport.DataSources.Add(reportDataSource);
reportViewer3.RefreshReport();
我真的希望有人帮我,因为我很失落。。我试了一整天,但找不到任何解决我问题的办法。
我试过这样做:
我的参数picture的值。=System.Convert.FromBase64String(参数!picture.Value)
代码:
public string ConvertImgToBase64String()
{
byte[] arrpic;
using (MemoryStream ms = new MemoryStream())
{
picEmployee.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
arrpic = ms.ToArray();
}
string base64String = Convert.ToBase64String(arrpic);
return base64String;
}
ReportParameter Picture = new ReportParameter("picture", ConvertImgToBase64String());
reportViewer3.LocalReport.SetParameters(new ReportParameter[] { name, employee_id, company_id, emp_no, Picture });
但是图像没有,并且没有错误消息。
Dim arrPic as byte() = /*Load the image as array of byte
Convert byte() to BASE64 */
Dim sIMGBASE64 as String = Convert.ToBase64String(arrPic))
/*Add the BASE64 stream to the parameters*/
paramList1.Add(New ReportParameter(<sparamname>, sIMGBASE64)
在报告上设置图片框的"值"属性,如下所示:
Value=System.Convert.FromBase64String(Parameters!<sparamname>.Value)
请在您的代码中尝试此操作