winforms .rdlc 数据报告中的外部图像
我在 Google 上搜索了几天以在 .rdlc 数据报告上显示图像,但仍然没有找到解决方案。
我已经设置:
reportViewer1.LocalReport.EnableExternalImages = true;
图像属性设置为“外部”,并将参数值设置为 value 属性。
ReportParameter Path;
Path = new ReportParameter("Path", "C:\\Test\\579569.png");
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { Path });
但我仍然得到一个破碎的图像。有什么我遗漏的吗?我正在 WinForms 中尝试这个。 我知道其他人问过这个问题..但我没有得到我想要的结果。
提前致谢
I searched Google for days to show images on .rdlc datareports but still not found a solution.
I have set:
reportViewer1.LocalReport.EnableExternalImages = true;
Image properties to "External" and have set parameters value to the value property.
ReportParameter Path;
Path = new ReportParameter("Path", "C:\\Test\\579569.png");
this.reportViewer1.LocalReport.SetParameters(new ReportParameter[] { Path });
But still i get a broken image. Is there something i am missing.I am trying this in WinForms.
I know this question is asked by others..but i didn't get the result that i wanted.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
@Praveen是对的。我使用
Server.MapPath
来获取图像的物理路径:然后我也设置了
reportViewer1.LocalReport.EnableExternalImages = true;
。@Praveen is right. I used
Server.MapPath
to get the physical path of the image:and then I set
reportViewer1.LocalReport.EnableExternalImages = true;
as well.图片网址必须使用格式
file:////F:\111\333.JPG
The image url must be using format
file:////F:\111\333.JPG
RDLC 中的路径必须是 URI,然后传递给 ReportParameter 的字符串是 AbsolutePath(在您的情况下 file:///C:/Test/579569.png)
Excuse VB.Net代码,但你明白了。
Your paths in an RDLC have to be URIs, then the string you pass to the ReportParameter is the AbsolutePath (in your case file:///C:/Test/579569.png)
Excuse VB.Net code but you get the idea.
您是否尝试过在 rdlc 文件中将 MIME Type 属性设置为 ImageControl ?
Have you tried setting MIME Type property to ImageControl in the rdlc file?
首先,在项目中的 Load 事件中创建一个新表单,
然后在该页面上添加 reportViewer 并设置其智能标记,选择“设计新报表”并从 ToolBox 中获取图像控件,设置其财产
注意: 图像(Sunset.jpg)保存在 D 盘的 Images 文件夹中。你按照你的要求改了。
Firstly, you take a new Form in your project on Load event you Wright this line below:
after that take reportViewer on that page and set smart tag of that, choose Design a new report and take an image control on it from ToolBox, set its property
Note: Image(Sunset.jpg) saved in Images folder on D drive. You changed it according to your requirement.
我在自己的项目中使用这些代码得到了结果
I got results using these codes in my own project
我知道这是一篇旧文章,但现在仍然相关。
我搜索了很多,大多数答案都是针对网站的。
我正在表单和本地图片文件中搜索 c# reportviewer。
使用这个效果很好:
在 rdlc 中添加图像。
将源设置为外部
则将值设置为 File:\C:\MyPics\logo.png,
如果路径存储在数据库中,
将值设置为 ="File:" +First(Fields!LogoFile.Value, "DataSet1")
我还在表单中添加了此代码(如果您愿意,可以直接在报表查看器控件的属性中设置它)
reportViewer1.LocalReport.EnableExternalImages = true;
I know this is for an old post but it is still relevant now.
I searched so much and most answers are for web sites.
I was searching for c# reportviewer in a form and a local picture file.
It worked well using this:
Add the image in rdlc.
set source to external
set the value to File:\C:\MyPics\logo.png
if the path is stored in database,
set the value to ="File:" +First(Fields!LogoFile.Value, "DataSet1")
I also added this code in my form (you can set it directly in reportviewer control's properties if you prefer)
reportViewer1.LocalReport.EnableExternalImages = true;