We can display crystal report in many format like pdf format , Exel Format . Word Fortmat.
Now using below code you can develop logic to display record in Browser also.
Import the following important namespace
using CrystalDecisions.CrystalReports;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Web;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web.Design;
Under CrystalReportViewer1_Init write down your data table or dataset code to retrieve data.
From database .
Make CrystalReportViewer1.EnableDatabaseLogonPrompt = false;
and write the code
Session["data"] = Session["data"].ToString();
if (Session["data"] != null)
{
lblPdf.Text = Session["Ft"].ToString();
if (lblpdf.Text == "Pdf")
{
YourReportObject.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "your dataAdapter Name or report name");
}
For Exel Format :-
Just Write ExportFormatType.Excel,
For WorFormat:-
ExportFormatType.RichText
Now using below code you can develop logic to display record in Browser also.
Import the following important namespace
using CrystalDecisions.CrystalReports;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Web;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Web.Design;
Under CrystalReportViewer1_Init write down your data table or dataset code to retrieve data.
From database .
Make CrystalReportViewer1.EnableDatabaseLogonPrompt = false;
and write the code
Session["data"] = Session["data"].ToString();
if (Session["data"] != null)
{
lblPdf.Text = Session["Ft"].ToString();
if (lblpdf.Text == "Pdf")
{
YourReportObject.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "your dataAdapter Name or report name");
}
For Exel Format :-
Just Write ExportFormatType.Excel,
For WorFormat:-
ExportFormatType.RichText
0 comments: