我使用stimulsoft报告从数据库收集图像数据,我使用变量将参数列表集合传递给我的报告,但它不起作用!! 我的代码如下所示:
var imgConverter = new ImageConvert();
var report = new StiReport();
var t = new DataTable();
t.Columns.Add("Img");
foreach (DataGridViewRow dgv in dataGridViewX3.Rows)
{
t.Rows.Add(
imgConverter.ByteArrayToImage((byte[])dgv.Cells["BarcodeImg"].Value)
);
}
report.Load("BarcodeReport.mrt");
report.RegData("DSBarcode", t);
report.Compile();
report.Show();
答案 0 :(得分:1)
我认为这个例子可以解决你的问题
DataSet ds = new DataSet(); System.Drawing.Image img =
System.Drawing.Image.FromFile(Server.MapPath("") +
"//image//titleLogo.jpg");
byte[] bytes = (byte[])(new ImageConverter()).ConvertTo(img, typeof(byte[]));
dtTicket = new DataTable(); dtTicket.Clear();
dtTicket.Columns.Add("imgLogo", typeof(byte[]));
Row = dtTicket.NewRow(); Row["imgLogo"] = bytes;
dtTicket.Rows.Add(Row); ds.Tables.Add(dtTicket);
答案 1 :(得分:0)
var imgConverter = new ImageConvert();
var report = new StiReport();
var t = new DataTable();
//you should be define type of object in overload DataTable Column
t.Columns.Add("img", typeof(Image));
foreach (DataGridViewRow dgv in dataGridViewX3.Rows)
{
t.Rows.Add(
imgConverter.ByteArrayToImage((byte[])dgv.Cells["BarcodeImg"].Value)
);
}
report.Load("BarcodeReport.mrt");
report.RegData("DSBarcode", t);
report.Compile();
report.Show();