RSS

Passing & Streaming images to CrystalReport at run-time !!

07 Aug

Sometimes, you want to make something abnormal in your application. One of these abnormal actions that you want to pass an image to your report (CrystalReport) at run-time stage of your application.

There are many articles and resources have been written in this topic, but all are complicated and take a hard code to do with incomplete way. You can follow the pictures to see how this ??

In your C# application you can send image path as following:

ReportDocument rpt = new ReportDocument();
rpt.Load(@”C:\Users\AhmedNegm\Desktop\CrystalReport1.rpt”);
rpt.DataDefinition.FormulaFields[“picPath”].Text = @”‘C:\MyImage.jpg'”;
crystalReportViewer1.ReportSource = rpt;

 

Tags: , , , , , , , , , , , , , , , , , ,

13 responses to “Passing & Streaming images to CrystalReport at run-time !!

  1. seerrr

    September 25, 2013 at 1:03 PM

    something wrong last picture i think ???

     
    • Eng. Ahmed Negm

      September 25, 2013 at 1:13 PM

      Thanks for your reply, but what do you think about this picture?

       
  2. seerrr

    September 28, 2013 at 11:25 AM

    I’m sorry for my English first 🙂 I tried what you said. But I didn’t add a photo to my crystal report. When I build the project it’s an error. The error is ‘ Error kind formula error’

     
  3. seerrr

    September 28, 2013 at 11:27 AM

    Last picture I did drag and drop after that save and close. and I wrote
    ReportDocument rpt = new ReportDocument();
    rpt.Load(@”C:\Users\AhmedNegm\Desktop\CrystalReport1.rpt”);
    rpt.DataDefinition.FormulaFields[“picPath”].Text = @”‘C:\MyImage.jpg’”;
    crystalReportViewer1.ReportSource = rpt;

    but I didn’t do it. Please help me

     
    • Eng. Ahmed Negm

      September 29, 2013 at 9:48 AM

      You have to replace the path of the report “C:\Users\AhmedNegm\Desktop\CrystalReport1.rpt” with your actual path, and the same thing with image path “C:\MyImage.jpg” .. it is working well, sure, you missed something 🙂

       
  4. hb

    December 6, 2013 at 7:09 PM

    It’s not working something kind error comes . I am doing it with vb.net

     
  5. Mike

    December 12, 2013 at 9:53 PM

    Hi, I´m doing the same that you but the image doesn’t display. When I export the CR to pdf the image is a blank square.

     
  6. Eng. Ahmed Negm

    December 19, 2013 at 2:15 PM

    Dears, this is a sample project proved that these steps are correct:
    https://www.dropbox.com/s/jqdj4oi2s3e2xzg/CR%20Image.rar

    I think that your fault is in the image path, you have to set the complete path of the image, please check the screenshot attached and the image is located on the Bin folder.

    Thanks for all

     
  7. efischency

    October 1, 2014 at 9:12 PM

    I was always curious about a good way to do this. Nice, simple tutorial… nice work and thank you!

     
  8. Toi

    March 19, 2015 at 3:22 AM

    How to do it in vb.net. please help me.

     
    • Ahmed Negm

      March 19, 2015 at 8:19 AM

      It’s the same idea but you have to write it in VB syntax

       

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: