FastReport.NET报表打印多张图片
FastReport报表预览
解决方案
报表数据源:DataSet/DataTable数据
报表的DataBand组件绑定BeforePrint事件
C# 全选
//打印图片,需要在BeforePrint事件内处理
detailBand.BeforePrint += new EventHandler(DetailBand_BeforePrint2);
BeforePrint事件代码参考
C# 全选
/// <summary>
/// 图片处理(北方款)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DetailBand_BeforePrint2(object sender, EventArgs e)
{
//取出当前正在打印的记录(DataRow)。
DataRow row = (sender as DataBand).DataSource.CurrentRow as DataRow;
//当前Report实例
var report = (sender as DataBand).Report;
//设置工序,工序打勾
ReportLib.ApplyProcessSettings(report, row);
//获取纸盒图片
var ListDetails = DataTableHelper.ConvertObject<res_PF_Process>(row);//强转获取从表
if (ListDetails.Cartonisid != null)
{
//获取纸盒图片的PictureObject组件
PictureObject pic = (sender as DataBand).Report.FindObject("Picture") as PictureObject;
//取图片参数
var input = new req_Images()
{
DocType = ImageDocType.Carton.ToString(),
DocNo = ListDetails.Cartonisid,
};
//从dt_Images中获取对应的图片
var ImgSmall = new bll_Images().GetByDocType(input);
if (ImgSmall != null)
{
Image img = ImageHelper.FromBytes(ImgSmall.ImgSmall);//将字节转换为图片
if (pic != null) pic.Image = new Bitmap(img); //注意:必须是Bitmap, Image不受支持!
}
else
{
if (pic != null) pic.Image = null;
}
}
//获取唛头图片
if (ListDetails.SOsisid != null)
{
//获取唛头图片的PictureObject组件
PictureObject pic = (sender as DataBand).Report.FindObject("Picture1") as PictureObject;
//从tb_AttachFile中获取对应的图片
var listImgSmall = new bll_AttachFile().GetData("SO", ListDetails.SOsisid);
if (listImgSmall.Count > 0)
{
Image img = ImageHelper.FromBytes(listImgSmall.FirstOrDefault().FileBody);//将字节转换为图片
if (pic != null) pic.Image = new Bitmap(img); //注意:必须是Bitmap, Image不受支持!
}
else
{
if (pic != null) pic.Image = null;
}
}
}
FastReport.NET报表模版
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
CSFrameworkV6 C/S框架网