Monday, 18 June 2007

External images in a local report

We've been playing with Reporting Services at work lately, in particular the use of Local Reports.

Adding external images to these reports is a bit fiddly. The "handling images" section of this devx article sheds some useful light on what the path must look like, and how to handle relative paths.

As local reports require an absolute path, one means of doing this to use an embedded VB.NET function:

Public Function GetAppPath() As String
Return System.AppDomain.CurrentDomain.BaseDirectory
End Function


Using this function, here's how you can set up the Value property of an image to point to the external image file.

=System.IO.Path.Combine(Code.GetAppPath(),"image.jpg")

2 comments:

Elistan said...

I think its actually System.IO.Path.Combine

:)

Lyndsay said...

Well spotted - thanks :-)