winforms .rdlc 数据报告中的外部图像

发布于 2024-08-17 22:46:28 字数 456 浏览 12 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

傲世九天 2024-08-24 22:46:28

@Praveen是对的。我使用Server.MapPath来获取图像的物理路径:

"file:///" + Server.MapPath("~/images/nokia.jpg")

然后我也设置了reportViewer1.LocalReport.EnableExternalImages = true;

@Praveen is right. I used Server.MapPath to get the physical path of the image:

"file:///" + Server.MapPath("~/images/nokia.jpg")

and then I set reportViewer1.LocalReport.EnableExternalImages = true; as well.

桃气十足 2024-08-24 22:46:28

图片网址必须使用格式 file:////F:\111\333.JPG

The image url must be using format file:////F:\111\333.JPG

塔塔猫 2024-08-24 22:46:28

RDLC 中的路径必须是 URI,然后传递给 ReportParameter 的字符串是 AbsolutePath(在您的情况下 file:///C:/Test/579569.png

    Dim filepath As Uri
    filepath = New Uri("C:\Test\579569.png")

    Dim Path As ReportParameter
    Path = New ReportParameter("Path", filepath.AbsolutePath)

    Me.reportViewer1.LocalReport.SetParameters(New ReportParameter() {Path})

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)

    Dim filepath As Uri
    filepath = New Uri("C:\Test\579569.png")

    Dim Path As ReportParameter
    Path = New ReportParameter("Path", filepath.AbsolutePath)

    Me.reportViewer1.LocalReport.SetParameters(New ReportParameter() {Path})

Excuse VB.Net code but you get the idea.

记忆消瘦 2024-08-24 22:46:28

您是否尝试过在 rdlc 文件中将 MIME Type 属性设置为 ImageControl ?

Have you tried setting MIME Type property to ImageControl in the rdlc file?

糖果控 2024-08-24 22:46:28

首先,在项目中的 Load 事件中创建一个新表单,

reportViewer1.LocalReport.EnableExternalImages = true;

然后在该页面上添加 reportViewer 并设置其智能标记,选择“设计新报表”并从 ToolBox 中获取图像控件,设置其财产

来源=外部

值 = 文件:\D:Images\Sunset.jpg

注意: 图像(Sunset.jpg)保存在 D 盘的 Images 文件夹中。你按照你的要求改了。

Firstly, you take a new Form in your project on Load event you Wright this line below:

reportViewer1.LocalReport.EnableExternalImages = true;

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

Source = External

Value = file:\D:Images\Sunset.jpg

Note: Image(Sunset.jpg) saved in Images folder on D drive. You changed it according to your requirement.

星星的軌跡 2024-08-24 22:46:28

我在自己的项目中使用这些代码得到了结果

var imagePath = new Uri(HostingEnvironment.MapPath("PATH")).AbsoluteUri;
lr.ReportPath = HostingEnvironment.MapPath("/Report/Test1.rdlc");
lr.EnableExternalImages = true;
lr.SetParameters(new ReportParameter[] { 
    new ReportParameter("Path", imagePath)
});

I got results using these codes in my own project

var imagePath = new Uri(HostingEnvironment.MapPath("PATH")).AbsoluteUri;
lr.ReportPath = HostingEnvironment.MapPath("/Report/Test1.rdlc");
lr.EnableExternalImages = true;
lr.SetParameters(new ReportParameter[] { 
    new ReportParameter("Path", imagePath)
});
ゞ记忆︶ㄣ 2024-08-24 22:46:28

我知道这是一篇旧文章,但现在仍然相关。
我搜索了很多,大多数答案都是针对网站的。
我正在表单和本地图片文件中搜索 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;

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文