原創(chuàng)|其它|編輯:郝浩|2012-08-28 01:50:16.000|閱讀 962 次
概述:本文介紹了.Net報表控件FastReport.Net在C#程序中如何邦定報表模版。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
1、首先在程序中引用dll
using FastReport;
using FastReport.Export.Pdf;
using FastReport.Data;
using FastReport.Format;
2、動態(tài)取得數(shù)據(jù),通過sql 邦定DataSet,如:
DataSet IDataSet = db.ExecuteSqlGetDataset(sql, "frform");
DataSet FDataSet = db.ExecuteSqlGetDataset(sql, "fritem");
3、加載模版邦定數(shù)據(jù)
Report report = new Report();
report.Load("Report\\test.frx");
//這里是為報告注冊數(shù)據(jù)第二個參數(shù)表示此數(shù)據(jù)在報告中的別名,就是和模版中的[frform.CName] frform對應(yīng)的名稱
report.RegisterData(IDataSet.Tables[0],"frform");
report.RegisterData(FDataSet.Tables[0], "fritem");
//找到 Databind 邦定數(shù)據(jù) 一定要先注冊數(shù)據(jù)才可以邦定
DataBand data = report.FindObject("Data1") as DataBand;
data.DataSource = report.GetDataSource("frform");
//如果有子報表的話還應(yīng)邦定子報告
DataBand datasubreport = report.FindObject("Data2") as DataBand;
datasubreport.DataSource = report.GetDataSource("fritem");
report.Prepare();
// 導(dǎo)出pdf
PDFExport export = new PDFExport();
report.Export(export, "PDF\\"+DateTime.Now.ToString("yyyyMMddHHmmss")+".pdf");
//顯示
report.Show();
// 釋放資源
report.Dispose();
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:網(wǎng)絡(luò)轉(zhuǎn)載