Click here to Skip to main content
15,917,618 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i get certain graphs on calculation and i need to display the images of graph in the crystal report in the report section. how to do that.
the following code i have written :
XML
/// <summary>
      /// To load the Image stored in the given filepath
      /// </summary>
      /// <param name="filePath"></param>
       private void LoadImage(string filePath)
       {
           //1) create an instance of type dataTable and store the images in it.
           DataTable imageTable = resultDataSet.Tables["GraphsImages"];
           // 2) insert the desired number of rows in the table that holds the images.
           DataRow newRow = imageTable.NewRow();
           // 3) get the image file into a stream reader.
           FileStream fs = new FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read);
           byte[] Image = new byte[fs.Length];
           fs.Read(Image, 0, Convert.ToInt32(fs.Length));
           fs.Close();

           newRow[0] = filePath;
           newRow[1] = Image;
           imageTable.Rows.Add(imageTable);

       }

and in the other method i call the loadimage function:
XML
/// <summary>
        /// Handles the Click event of the btnGenerateReport control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RoutedEventArgs" /> instance containing the event data.</param>
        private void btnGenerateReport_Click(object sender, RoutedEventArgs e)
        {
            string filePath = @"c:\temp\interaction.bmp";
            InteractionChart.SaveBitmap(filePath);
            //VolumeChart.SaveBitmap(@"c:\temp\volumechart.bmp");
            //NetTorqueChart.SaveBitmap(@"c:\temp\netTorqueChart.bmp");
            //NetWOBChart.SaveBitmap(@"c:\temp\netWOBChart.bmp");
            //AreaChart.SaveBitmap(@"c:\temp\areaChart.bmp");
            //DPCChart.SaveBitmap(@"c:\temp\DPCChart.bmp");
            //ForceChart.SaveBitmap(@"c:\temp\forcechart.bmp");
            //WearRateChart.SaveBitmap(@"c:\temp\wearRateChart.bmp");
            LoadImage(filePath);
            ReportGenerated(this);
        }


but i am not getting the image. how will i get it? very urgent.
Posted

1 solution

A possible solution could be that you try to load the image in the report itself via URI and then you could pass the URI as parameter to the report.

Never tried it though, but that's how I would (try to) do it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900