reporting services - SSRS External Images with Dynamic File Extensions -


i have report needs show images windows folder on server, working (see here ). now, wondering how report pull images of differing file types, jpg & tif. (i using png default). there relatively easy way this? image names file extension not in sql database.

edit: entered in custom code block, daniel's below.

public function getimage(byref filename string) string ' full image path used testing if exists dim imagepath string imagepath = "\\gvsserver1\gvsserverd\acclamare_images\" + filename ' test see if file exists gif try if system.io.file.exists(imagepath + ".png") return "file://" + imagepath + ".png" elseif system.io.file.exists(imagepath + ".jpg") else return "file://" + imagepath + ".jpg" end if catch ex exception return "hit error" end try return "hit end" end function
when run report, fetches .jpg extension though image file png, , there isn't jpg file item. idea on how correct that?
edit 2: wasn't having success updated custom code, have been missing something, i'm no expert custom code. found question (see here) function. tried , works, except reason .tif files don't display on report. installed microsoft picture manager (from sharepoint exe download), still doesn't display .tif files.

the news definetely possible, takes bit of custom code , server side tweaking ready.

general idea: create code behind function takes name of our image , file existence tests determine file extension type exists on network share.

if right-click outside of report area , go properties, see custom code window can paste following function code.

custom code:

public function getimage(byref filename string) string     ' full image path used testing if image exists     dim imagepath string     imagepath = "\\em-ssrs\imagetest\" + filename      ' test see if file exists gif     if system.io.file.exists(imagepath + ".gif")              return "file://" + imagepath + ".gif"     elseif system.io.file.exists(imagepath + ".png")              return "file://" + imagepath + ".png"     elseif system.io.file.exists(imagepath + ".jpg")              return "file://" + imagepath + ".jpg"     elseif system.io.file.exists(imagepath + ".jpeg")              return "file://" + imagepath + ".jpeg"     end if      return "no image exists" end function 

you have edit imagepath variable contain network share path scenario or add parameter function make more generic if wish.

once code function created, advise creating dummy textbox expression on report , using following value:

=code.getimage("filenmame") 

which allow view output of function , tweak things needed. note "file:// ... " syntax may not work within report builder or visual studio , may have deployed report server testing.

of course, once looks function working, add image, make sure set source external , use same expression textbox.

server side changes

upon further testing on own environment, i've had make 2 additional changes work:

  1. ensure unattended execution account set domain account has permission file share

  2. edit ssrs config in rssrvpolicy.config file trust custom code , allow execution of file.exists function specifying "fulltrust"

<codegroup   class="unioncodegroup"   version="1'   permissionsetname="fulltrust"   name="report_expressions_default_permissions"   description="this code group grants default permissions code in report expressions , code element."   ... </codegroup> 

i did restart ssrs service after making these changes (i assume that's required, did precaution)

note not ssrs server admin , else may able add additional information custom policy change. glancing through ms documentation, there recommendation using custom assemblies instead take part grain of salt.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -