Click here to Skip to main content
15,881,687 members
Articles / Web Development / ASP.NET

Crystal Reports WebPart for SharePoint

Rate me:
Please Sign up or sign in to vote.
4.56/5 (5 votes)
6 Oct 2009CPOL6 min read 197.9K   4.3K   26  
An article on building a SharePoint WebPart to dynamically display Crystal Reports.
using System;
using System.Collections.Generic;
//using System.Linq;
using System.Web;
using System.Web.UI;
using System.IO;
using System.Web.UI.WebControls;

using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Web;


public partial class CrystalImageHandler : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        // get the Crystal Reports temporary file name
        String strtempImagePath = Request.QueryString["dynamicimage"];
 
        if (strtempImagePath != null)
        {
            // send the temporary image file
            SPWeb thissite = SPControl.GetContextWeb(Context);
            String strsitename = thissite.Site.HostName;
            int iport = thissite.Site.Port;
            String strport = Convert.ToString(iport);
            Response.TransmitFile(@"C:\WINDOWS\Temp\cr_tmp_image__" + strsitename + strport + "\\" + strtempImagePath);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
CEO Computation Limited
New Zealand New Zealand
Ray Goddard currently runs his own software business and is deep into writing internet based applications and trying to keep track of new developments.

Comments and Discussions