简体   繁体   English

尚未为此报告设置 enable externalimages 属性?

[英]The enable externalimages property has not been set for this report?

I am trying to add an external photo as the logo along with the report on the report.rdlc file.我正在尝试添加外部照片作为徽标以及关于report.rdlc文件的报告。 I have this error我有这个错误

The enable externalimages property has not been set for this report尚未为此报告设置 enable externalimages 属性

在此处输入图片说明 ? ?

Here is my code.这是我的代码。

 try
{
    this.pedidosTableAdapter.Connection.ConnectionString = con.MysqlConnect();

    this.pedidosTableAdapter.Fill(this.fabricacaoDataSet8.pedidos, Pages.relatorios.num);
    this.reportViewer1.RefreshReport();
}
catch { }

// for external image
this.reportViewer1.LocalReport.EnableExternalImages = true;
ReportParameter parm = new ReportParameter();
parm=(new ReportParameter("path", @"C:\logo.jpg",true));
this.reportViewer1.LocalReport.SetParameters(parm);
this.reportViewer1.Refresh();

I have experience when you enable external images using Code, it works on local / development environment but while deployment on server it does not works and reports raise error:当您使用代码启用外部图像时,我有经验,它适用于本地/开发环境,但在服务器上部署时它不起作用并报告引发错误:

"The enable external images property has not been set for this report" “尚未为此报告设置启用外部图像属性”

In order to solve this issue, use EnableExternalImages="true" property in ASPX or design file where you are using ReportViewer Control and it will work perfectly.为了解决这个问题,在 ASPX 或您使用 ReportViewer 控件的设计文件中使用EnableExternalImages="true"属性,它将完美运行。

The problem here actually is, that you're calling this.reportViewer1.RefreshReport();这里的问题实际上是,您正在调用this.reportViewer1.RefreshReport(); before setting this.reportViewer1.LocalReport.EnableExternalImages = true;在设置this.reportViewer1.LocalReport.EnableExternalImages = true;之前this.reportViewer1.LocalReport.EnableExternalImages = true; . .

The order is important here.顺序在这里很重要。

As mentioned here , the path of the image must be in URL format, ie @"file:///C:\\logo.jpg"这里所说,图片的路径必须是URL格式,即@"file:///C:\\logo.jpg"

Or you can try或者你可以试试

var filepath = new Uri("C:\logo.jpg");
var path = new ReportParameter("Path", filepath.AbsolutePath);
this.reportViewer1.LocalReport.SetParameters(new ReportParameter {Path = path});

I hope this image is a help in your Windows Application.Activate your Reportviewer->Properties->LocalReport->EnableExternalImage and set it to True我希望此图像对您的 Windows 应用程序有所帮​​助。激活您的 Reportviewer->Properties->LocalReport->EnableExternalImage 并将其设置为 True 在此处输入图片说明

For WinForm Applications, below code will works well.对于 WinForm 应用程序,下面的代码将运行良好。

string templateImage = Application_Path + @"\Images\ReportLogo.jpg";
rvRptContainer.LocalReport.EnableExternalImages = true;
rvRptContainer.LocalReport.SetParameters(new ReportParameter("ReportLogo", "File:\\" + templateImage));

For ASP.Net Applications, Do the following:对于 ASP.Net 应用程序,请执行以下操作:

ReportViewer1.LocalReport.EnableExternalImages = true;

    string imagePath = new Uri(Server.MapPath("~/images/Mudassar.jpg")).AbsoluteUri;

    ReportParameter parameter = new ReportParameter("ImagePath", imagePath);

    ReportViewer1.LocalReport.SetParameters(parameter);

    ReportViewer1.LocalReport.Refresh();

Nothing worked for me, But simply this worked没有什么对我有用,但是这很有效

        LocalReport localReport = new LocalReport();
        localReport.ReportPath = HostingEnvironment.MapPath("~/Reports/myreport.rdlc");
        localReport.EnableExternalImages = true;
        localReport.EnableHyperlinks = true;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM