SQL Server How to Display Images from a Website within an SSRS Report Run on the Server

zbwhf8kr  于 9个月前  发布在  其他
关注(0)|答案(3)|浏览(64)

I have a small web site where I maintain user data, and I maintain the user data in a table that stores their image using a relative URL on the website, like "/images/users/user_id.jpeg".

I am using the ReportViewer control in the asp.net page to show reports from SSRS in the web application.

Now our users want reports to show their image in reports that they can export as pdf and print.

In the SSRS report I tried using an HTML image tag with both full and relative URLs with the option to render HTML, however it's not working.

I tried using the image control in the toolbox with an external URL and that also appears to be not working.

Can someone please help me get around this problem or guide me to some helpful links.

Thanks all.

kzmpq1sx

kzmpq1sx1#

I tried everything!!! It wasn't working in BIDS, Web Browser nor a Winform Report Viewer control.

I ended up hard-coding the image and it still didn't work:

="http://MyServer/Reports_SQL2008/Pages/Resource.aspx?ItemPath=%2fProjectReporting%2fBRAND_Logo.png&RetrieveResource=True"

I am pretty sure the problem was something to do with Active Directory Group Policy propagation. I suggest to leave it overnight if you have the same problem and have tried everything you can think of:

  1. Setup Unattended Execution Account in SSRS Config with a service account who's password wont expire:

  1. Permissions (both on image and also at Site Settings):

  1. Can navigate to the image successfully, but it still doesn't show in the report.

  1. Have the SSRS Image Properties set correctly, with the equal sign and url enclosed in double quotes, ie: ="url"

  1. Even clear your browsers cache and tried different browsers, etc, etc

Anyway next morning I tried and the hardcoded path works and now this dynamic URL works too:

http://MyServer/Reports_SQL2008/Pages/Resource.aspx?ItemPath=%2fProjectReporting%2f " & First(Fields!Brand.Value, "ClientAndBrandByAccount") & "_Logo.png&RetrieveResource=True"

The XML in the RDL file is HTML encoded and looks like this:

<Image Name="Logo">
 <Source>External</Source>
  <Value>="http://MyServer/Reports_SQL2008/Pages/Resource.aspx?ItemPath=%2fProjectReporting%2f" &amp; First(Fields!Brand.Value, "ClientAndBrandByAccount") &amp; "_Logo.png&amp;RetrieveResource=True"</Value>

I tried to make the Server URL dynamic as Alex Z shows, though I had to use this Replace code:

=Replace(Globals!ReportServerUrl,"/ReportServer_","/Reports_") & "/Pages/Resource.aspx?ItemPath=%2fProjectReporting%2f" & First(Fields!Brand.Value, "ClientAndBrandByAccount") & "_Logo.png&RetrieveResource=True"
yr9zkbsy

yr9zkbsy2#

It will be a lot easier to set up the report so that your users can see the image, if you can see the image in preview in Report Designer.

  1. Make sure you have a working URL that takes you to one of your images. Test it, by pasting the URL into the address bar of your browser and ensure that the image is displayed in the browser.
  2. Delete the existing image from your report. Insert a new image into the report object (normally a list or table) you are using to display your table. (This should be where the old image was.)
  3. Specify Web as the image source, and enter your working URL as the URL of the image.
  4. Preview the report in the report designer. You should be able to see the image (with the hardcoded URL) displayed correctly in the report.
  5. Assuming all images are stored in the same directory on your server, switch to the layout tab of your report designer and click on the image object. In the Properties window, the value attribute should be the harcoded URL.
  6. Click on the <Expression...> option from the dropdown menu for the Value attribute. Edit the expression so that it says ="your URL, without the filename" & Fields!your image filename data field name.Value
  7. Preview the report in the report designer. You should be able to see the appropriate image for your data displayed correctly in the report.
  8. If everything has gone correctly up to this point, deploy the report and try viewing it in the Report Manager. You should be able to see the appropriate image for your data displayed correctly in the report.

At this point, your users should now be able to see the report images.

toiithl6

toiithl63#

Create a relative url using the expression and global variable Globals!ReportServerUrl

= Globals!ReportServerUrl + "your path to image"

相关问题