Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I am currently doing this, however, it was not easy to achieve.</p> <p>I created a class that generates RDLC files in a MemoryStream. The RDLC memory stream is sent to the reportViewer control, which in turn displays the report.</p> <p>During the generation of the RDLC file, you can create an embedded image. In order to do this, I retrieve the image into a Byte array, then I convert the Byte array into Base64 Encoding. The RDLC files require Base64 encoding for images to display properly.</p> <p>Again, it was not easy to achieve, so you will really need to want to do this in order to pull it off. If you want to proceed with this method, I can give you some more details.</p> <p><strong>EDIT</strong> (More details)</p> <p>You can get some sample code on how to dynamically create RDLC files at <a href="http://gotreportviewer.com/" rel="nofollow noreferrer">GotReportViewer</a>. Direct link to code for <a href="http://gotreportviewer.com/DynamicTableVB.zip" rel="nofollow noreferrer">VB.NET</a> and <a href="http://gotreportviewer.com/DynamicTable.zip" rel="nofollow noreferrer">C#</a>.</p> <p>If you can manage to figure out how that code works, you will be able to generate your RDLC files, and won't need to manually create the files yourself. Again, I need to stress the fact that you will be tinkering a lot to get to where you want to be with this.</p> <p>Now, in order to generate images, retrieve it from the database. When you get it back from the database (I use BLOBs), you will get a Byte array. The Byte array holds the data for the image, but I cannot be used in its current state. To convert it, you can do something like this:</p> <pre><code>Dim output As String = "" output = Convert.ToBase64String(imgByteArray) </code></pre> <p>The resulting output string will be compatible with ReportViewer. Now you can dynamically add this string into the ReportViewer's RDLC file (XML file). Using the code examples from GotReportViewer, you could do the following:</p> <pre><code> 'Inserts embedded images into the report Overridable Function CreateEmbeddedImages() As Rdl.EmbeddedImagesType Dim bgCell As New Rdl.EmbeddedImageType Dim images As New Rdl.EmbeddedImagesType bgCell.Name = "bgTableHeader" bgCell.Items = New Object() {"image/jpeg", output} bgCell.ItemsElementName = New Rdl.ItemsChoiceType35() {Rdl.ItemsChoiceType35.MIMEType, Rdl.ItemsChoiceType35.ImageData} images.EmbeddedImage = New Rdl.EmbeddedImageType() {bgCell} Return images End Function </code></pre> <p>The RDL type is the Report Definition Language Class file. Basically, its a reverse engineered RDLC XSD Schema. It contains classes that will be used to generate a valid XML file for your reports. It is included in the GotReportViewer link up top, but you can generate one yourself using the XSD.EXE tool provided with Visual Studio.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload