5 Jun 2009

Mengakses crystal report Visual Web Developer 2005 Express Edition

Bagaimana mengakses crystal report menggunakan Visual Web Developer 2005 Express Edition.

Crystal Reports bukan bagian dari Visual Web Developer 2005 Express atau . NET Framework. Anda perlu membeli VS Professional edition 2005.
Jika Anda memiliki Crystal Reports XI atau X, maka anda dapat menginstal. NET libraries untuk Crystal Reports pada Visual Web Developer 2005 Express Edition.
Setelah itu :

1)Kamu dapat menambahkan namespaces berikut ini ke code-behind-mu (using C#):

using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Web;


2) Kamu dapat menambahkan referensi ke Crystal Reports DLLs di web.config di compilation node di system.web node:

[assemblies]
[add assembly="CrystalDecisions.CrystalReports.Engine, ..." /]
[add assembly="CrystalDecisions.Shared, ... "/]
[add assembly="CrystalDecisions.ReportSource, ..." /}
[add assembly="CrystalDecisions.Web, ..." /]
[/assemblies]

Di masing tag yg ditambahkan

assembly="CrystalDecisions.Web, Version=, Culture=neutral, PublicKeyToken="

Lihat di .NET Framework Configuration tool di the Administrative Tools di Control Panel untuk informasi ini setelah menginstall Crystal Reports.
Coba ini untuk menampilkan reportnya :
Viewer.aspx

[%@ Page Language="C#" CodeFile="Viewer.aspx.cs" Inherits="Viewer" %]
[%@ Register Assembly="CrystalDecisions.Web, Version=11.0.3300.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" Namespace="CrystalDecisions.Web" TagPrefix="CR" %]
[html]

[body]

[form id="frmCRBasic" runat="server"]

[p]

[asp:Button ID="btnFirst" runat="server" /]

[asp:Button ID="btnPrev" runat="server" /]

[asp:Button ID="btnNext" runat="server" /]

[asp:Button ID="btnLast" runat="server" /]

Page

[asp:Label ID="lblPage" runat="server" /]

   

[asp:Button ID="btnPDF" runat="server" /]

[/p]

[p]

[CR:CrystalReportViewer ID="crBasic" runat="server" /]

[/p]

[/form]

[/body]

[/html]

ket : [ ] gantilah dengan < >

Viewer.aspx

using CrystalDecisions.CrystalReports.Engine;

using CrystalDecisions.Shared;

using CrystalDecisions.Web;

using System;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

public partial class Viewer : Page

{

#region Declared Objects

protected DiskFileDestinationOptions dfReport;

protected ExportOptions xoReport;

protected ReportDocument rdReport;

protected ServerFileReport sfReport;

#endregion

public void crBasic_Navigate(Object objSender, NavigateEventArgs evtArgs)

{

lblPage.Text = evtArgs.NewPageNumber.ToString();

}

public void btnFirst_Click(Object objSender, EventArgs evtArgs)

{

crBasic.ShowFirstPage();

}

public void btnPrev_Click(Object objSender, EventArgs evtArgs)

{

crBasic.ShowPreviousPage();

}

public void btnNext_Click(Object objSender, EventArgs evtArgs)

{

crBasic.ShowNextPage();

}

public void btnLast_Click(Object objSender, EventArgs evtArgs)

{

crBasic.ShowLastPage();

}

public void btnPDF_Click(Object objSender, EventArgs evtArgs)

{

rdReport = new ReportDocument();

sfReport = new ServerFileReport();

sfReport.ObjectType = EnumServerFileType.REPORT;

sfReport.ReportPath = "C:\\Web\\ReportName.rpt";

sfReport.WebServiceUrl = "http://localhost/crystalreportviewers11/ServerFileReportService.asmx";

dfReport = new DiskFileDestinationOptions();

dfReport.DiskFileName = "C:\\Web\\Temp\\temp.pdf";

xoReport = rdReport.ExportOptions;

xoReport.DestinationOptions = dfReport;

xoReport.ExportDestinationType = ExportDestinationType.DiskFile;

xoReport.ExportFormatType = ExportFormatType.PortableDocFormat;

rdReport.Export();

Response.ClearContent();

Response.ClearHeaders();

Response.ContentType = "application/pdf";

Response.WriteFile("C:\\Web\\Temp\\temp.pdf");

Response.Flush();

Response.Close();

}

protected void Page_Init(Object objSender, EventArgs evtArgs)

{

btnFirst.Click += new EventHandler(btnFirst_Click);

btnLast.Click += new EventHandler(btnLast_Click);

btnNext.Click += new EventHandler(btnNext_Click);

btnPDF.Click += new EventHandler(btnPDF_Click);

btnPrev.Click += new EventHandler(btnPrev_Click);

crBasic.Navigate += new NavigateEventHandler(crBasic_Navigate);

}

protected void Page_Load(Object objSender, EventArgs evtArgs)

{

if (!IsPostBack)

{

lblPage.Text = "1";

}

btnFirst.Text = "First";

btnPrev.Text = "Previous";

btnNext.Text = "Next";

btnLast.Text = "Last";

btnPDF.Text = "Export to PDF";

sfReport = new ServerFileReport();

sfReport.ObjectType = EnumServerFileType.REPORT;

sfReport.ReportPath = "C:\\Web\\ReportName.rpt";

sfReport.WebServiceUrl = "http://localhost/crystalreportviewers11/ServerFileReportService.asmx";

crBasic.DisplayGroupTree = false;

crBasic.DisplayToolbar = false;

crBasic.ReportSource = sfReport;

crBasic.DataBind();

}

}


Kamu dapat membeli Visual Studio .Net atau lihat salah satu situs crystal report berikut ini ::
http://www.crystalreports.co.uk/
Kamu bisa mencoba versi trial terlebih dahulu sebelum membeli.

Related Posts by Categories



0 komentar:

:nangis :rate :lebay :hoax :nyimak :hotnews :gotkp :wow :pertamax :lapar :santai :malu :ngintip :newyear.

Posting Komentar