Does anyone has got working example of Crystal Report Viewer or MS Reporting Services Viewer?


Would be nice if separate extension projects created by WiseJ for Crystal Report viewer and MS Reporting Services as these are used quite heavily in database projects?

  • You must to post comments

I am using the CR Viewer with all my WiseJ apps, and this method works on any Tablet we have used so far. I first populate an XML file on the server with the relevant data (that matches the dataset and rpt file). Then I send the xml file and the rpt file to a SEPERATE asp page (which I call from WiseJ) passing the location of the XML file and the rpt file (GET parameters as part of the URL). See below for various files… (oh, and to save headache, I copy the relevant CR files into a subdirectory on the webserver as well – Had issues with older apps using different versions of CR). Hope these samples help, you will obviously tweak to your own needs.

<%@ Page Language=”C#” AutoEventWireup=”true” CodeBehind=”report.aspx.cs” Inherits=”xxxx” %>
<%@ Register assembly=”CrystalDecisions.Web, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692fbea5521e1304″ namespace=”CrystalDecisions.Web” tagprefix=”CR” %>
<!DOCTYPE html>
<html xmlns=””>
<head runat=”server”>
<title>Report Display</title>
<form id=”report” runat=”server”>
<CR:CrystalReportViewer ID=”crystalReportViewer” runat=”server” AutoDataBind=”true” />

using System;
using CrystalDecisions.CrystalReports.Engine;
using xxxx;

namespace xxxxx
public partial class report : System.Web.UI.Page {
ReportDocument viewerSource = null;

protected void Page_Load(object sender, EventArgs e)  {

string qsXmlFilename = Request.QueryString[“xfn”];
string qsViewerSource = Request.QueryString[“vs”];
Type t = Type.GetType(qsViewerSource);
viewerSource = (ReportDocument)Activator.CreateInstance(t);

xxxx.printSetViewer(viewerSource, qsXmlFilename); // This sub you will have to create to populate – sample provided below

crystalReportViewer.ReportSource = viewerSource;
crystalReportViewer.DisplayStatusbar = false;
crystalReportViewer.DisplayToolbar = true;
crystalReportViewer.EnableDrillDown = false;
crystalReportViewer.EnableDatabaseLogonPrompt = false;
crystalReportViewer.EnableParameterPrompt = false;
crystalReportViewer.EnableToolTips = false;
crystalReportViewer.HasCrystalLogo = false;
crystalReportViewer.HasDrilldownTabs = false;
crystalReportViewer.HasDrillUpButton = false;
crystalReportViewer.HasPageNavigationButtons = true;
crystalReportViewer.HasToggleGroupTreeButton = false;
crystalReportViewer.HasToggleParameterPanelButton = false;
crystalReportViewer.PrintMode = CrystalDecisions.Web.PrintMode.Pdf;
crystalReportViewer.SeparatePages = false;
crystalReportViewer.ShowAllPageIds = false;
crystalReportViewer.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;

Web.config additions:
<sectionGroup name=”businessObjects”>
<sectionGroup name=”crystalReports”>
<section name=”rptBuildProvider” type=”CrystalDecisions.Shared.RptBuildProviderHandler, CrystalDecisions.Shared, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, Custom=null” />
<section name=”crystalReportViewer” type=”System.Configuration.NameValueSectionHandler” />
<add embedRptInResource=”true” />
<add key=”ResourceUri” value=”/crystalreportviewers” /> <!– Set your path to the CR folder on your server –>

Sample of Function:
public static void printSetViewer(ReportDocument objReport, string tmpFile)  {
DataSet ds = new DataSet();
objReport.SetDatabaseLogon(“”, “”, tmpFile, ds.DataSetName.ToString());

ConnectionInfo crConnInfo = new ConnectionInfo();
crConnInfo.ServerName = tmpFile;
crConnInfo.DatabaseName = ds.DataSetName.ToString();
crConnInfo.UserID = “”;
crConnInfo.Password = “”;
crConnInfo.Type = ConnectionInfoType.MetaData;

TableLogOnInfo tblTempLogonInfo = new TableLogOnInfo();
foreach (Table tbl in objReport.Database.Tables)  { // CR hates it if you don’t assign login info to Tables in your Dataset
tblTempLogonInfo = tbl.LogOnInfo;
tblTempLogonInfo.ConnectionInfo = crConnInfo;
tblTempLogonInfo.TableName = tbl.Name;
tblTempLogonInfo.ReportName = objReport.Name;
tbl.Location = tbl.Name;

  • You must to post comments

can the PDF viewer bar be visible when on a mobile device? Reason being we would like to print the PDF from iPhone / iPad.

  • You must to post comments

You need to use the PdfViewer. The CR viewer for winforms cannot in the browser. In alternative you can use the CR ASP.NET viewer. I find the PdfViewer to be much better than the ASP.NET viewer.

This is all you need:

 var report = new ReportDocument();
 report.FileName = Application.MapPath("CrystalReport1.rpt");
 this.pdfViewer1.PdfStream = report.ExportToStream(ExportFormatType.PortableDocFormat);


  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.