If you ever wanted to export SectionReports from ActiveReports 7 to JPEG image files and thought that it was a dead end, then you may not be aware of the the flexibility that ActiveReports offers. Let's get into the technicality of this subject and make our way through exporting SectionReports to JPEG Files.

When the Run method is invoked on the Section Report instance, it populates the Section Report document with a collection of static pages. These static pages are internally represented by a Page Class.  The Page Class includes a Draw method, which allows rendering the page's content to the specified graphics object at the specified coordinates, therefore you can easily draw a specified page to a graphics object and hence save each Page of the Section Report document to a JPEG File.

Here is a summary of steps required to export a SectionReport to JPEG:

  1. Create an instance of the report and call the Run method.

  2. Create a graphics object from an Image.

  3. Draw a specified Section Report Page object to the graphics object using the Draw method of the Page Class.

  4. Save the Image to a specified location.


Following code snippet implements the above steps.


private void ExportJpeg(GrapeCity.ActiveReports.Document.SectionDocument ReportDocument, string folderSavePath)
{
int pageindex = 0;
foreach (GrapeCity.ActiveReports.Document.Section.Page _pg in ReportDocument.Pages)
{
_pg.Units = GrapeCity.ActiveReports.Document.Section.Units.Pixels;
Bitmap bmp = new Bitmap((int)_pg.Width, (int)_pg.Height);
Graphics g = Graphics.FromImage(bmp);
g.FillRectangle(new SolidBrush(Color.White), 0, 0, bmp.Width, bmp.Height);
_pg.Draw(g, new RectangleF(0, 0, _pg.Width, _pg.Height));
bmp.Save(folderSavePath +"\\" +"Page" + (pageindex + 1).ToString() + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
pageindex++;
}
}


Refer to the attached samples for complete implementation.

Download C# Sample
Download VB Sample