จริงๆ แล้ว เราสามารถเปิด
crystal report
ได้หลาย format ค่ะ เช่น ใช้ pdf, Excel, Word
ส่วนด้านล่างนี้เป็นโค้ดสำหรับ
display record
ใน Browser ค่ะ
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;
และใต้ CrystalReportViewer1_Init
ให้เขียนโค้ดของ data table หรือไม่ก็ dataset
เพื่อดึงข้อมูลที่ต้องการ
From database .
กำหนดให้ CrystalReportViewer1.EnableDatabaseLogonPrompt = false;
และเขียนโค้ดดังต่อไปนี้
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");
}
สำหรับ Excel Format :-
ให้เขียน ExportFormatType.Excel,
สำหรับ Word Format:-
ให้เขียน ExportFormatType.RichText
Supa Sethasiripong [MSFT]
MSDN Community Support |
Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.