[转帖]在RDLC中使用外部图片
2015-03-10 16:17
274 查看
原文链接:http://blog.csdn.net/rock870210/article/details/4559962
在RDLC中使用外部图片
2009-09-16 19:08 3416人阅读 评论(5) 收藏 举报list报表数据库fileimagetable
关于在报表中添加图片的内容,网上有很多。但一直没找到合适的,今天才发现一个方法给了我提示,现在把它写出来,希望能帮助和我一样聚到问题的朋 友: 在ReportViewer中添加RDLC就不细说了,这里说明我的情况,我在报表中要显示作品下载信息,其中包含的有作品的缩微图,图片物理文件存在 项目中,数据库中保存的为相对路径。在RDLC中的Table相应列添加一个Image,设定其Source属性为External,Value属性为数 据源相应字段(图片路径)值,我是用List《》集合添加的,value值得格式为:="file:///" & Fields!CUPDLR_ProSmallLogoPath.Value(CUPDLR_ProSmallLogoPath为数据库相应字段),这里的”file:///“是非常重要的,不能缺省。后面接的是图片的物理路径,在cs文件中我已改动 至此,RDLC已基本设定好。在cs文件中:
[c-sharp] view plaincopy
protected void BindReportViewer(int year, int month) {
int proCount = 0;//记录作品数目
//获取list集合
List list = BComUserProDownLoadReport.GetList(year, month, comId,out proCount);
UpdateImgURL(list);//修改图片相对路径为物理路径
//this.ReportViewer1.LocalReport.EnableHyperlinks = true;
this.ReportViewer1.LocalReport.EnableExternalImages = true;//设定EnableExternalImages属性为TRUE,允许使用外部图片(默认是不允许的)
ReportParameter param1 = new ReportParameter("CurrentDate", year.ToString() + "-" + month.ToString());//构造报表参数-查询年月
ReportParameter param2 = new ReportParameter("CompanyName", "金长城");//构造报表参数-公司名称
ReportParameter param3 = new ReportParameter("ProductCount", proCount.ToString());//构造报表参数-作品数目
ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { param1, param2,param3 });//为报表参数指定值
//实例化报表查看器数据源
ReportDataSource rds = new ReportDataSource("ComUserProDownLoadReportDataSet_DataTable1", list);
this.ReportViewer1.LocalReport.DataSources.Clear(); this.ReportViewer1.LocalReport.DataSources.Add(rds);
this.ReportViewer1.LocalReport.Refresh();
}
//修改图片相对路径为物理路径
protected void UpdateImgURL(List list) {
foreach (ADOnline.Model.ComUserProDownLoadReport cplr in list) {
if (cplr.CUPDLR_ProSmallLogoPath != null && cplr.CUPDLR_ProSmallLogoPath.Trim().Length > 0)
cplr.CUPDLR_ProSmallLogoPath = Server.MapPath(cplr.CUPDLR_ProSmallLogoPath);
}
}
显示外部图片的关键部分就是file:///+图片物理路径,其他的根据自己需求做相应的更改吧!时间关系,不再啰嗦了!
相关文章推荐
- 在RDLC中使用外部图片
- geotools使用外部图片
- [RDLC] - RDLC报表显示外部图片方法
- 使用Gridview绑定数据库中的图片【转帖】
- RDLC 报表 引用外部图片 file用相对路径 开发工具vs2015
- AS3 使用Loader对象加载外部图片
- android adt使用外部图片资源
- android中图片加载使用LruCache缓存到内存或外部文件的功能
- 【.Net码农】RDLC报表显示外部图片方法
- RDLC 文档调用外部图片问题
- NGUI使用教程(3) 使用外部图片制作Atlas(图集)
- 單純使用PHP腳本不借助任何外部库或图片以及字体产生动画效果的Gif验证码图片
- 單純使用PHP腳本不借助任何外部库或图片以及字体产生动画效果的Gif验证码图片
- 使用Gridview绑定数据库中的图片【转帖】
- 使用libpng显示外部png图片
- NGUI使用教程(3) 使用外部图片制作Atlas(图集)
- Spring使用外部属性文件以及常见错误(内附大量图片,很有借鉴意义)
- myeclipse使用外部图片
- 使用php代码从网页中提取有效图片地址
- 如何使用java程序界面上的按钮启动外部的exe程序