FastReport使用心得javascript
1、準備html
一、此次開發使用的是FastReport桌面版(FastReport.Net Version 201731.16 Demo)java
二、引用類庫FastReport.dll、FastReport.Web.dllajax
2、桌面版製做報表數據庫
一、添加數據源服務器
Report------Add Data Source------測試
鏈接數據庫,測試鏈接成功,選取數據表,字段自動帶出到界面ui
若是數據源中增長了額外的數據字段,須要注意字段的屬性須要保持一致,Calculated屬性設置爲Falseurl
二、畫報表頁面spa
使用table,直接拖拽數據字段至指定位置便可
三、報表文件的處理
FastReport文件本質是XML形式的鍵值對,
<Dirctionary></Dirctionary>標籤下的<MsSqlDataConnection></MsSqlDataConnection>刪除,注意是刪除標籤對。這裏刪除的緣由是,咱們是使用的是桌面版FastReport製做報表,可是是用網頁版來調用文件,網頁版只傳DataSource給FastReport文件。
<Dirctionary></Dirctionary>標籤下的<TableDataSource>的屬性須要調整,除了Name、TableName須要與提供的數據源的表名XXX對應外,還須要增長一個屬性ReferenceName,值爲XXX.XXX。
3、Web程序調用文件
用於展現報表的首頁,使用ajax形式訪問服務器獲取數據並填充到頁面內。
服務器數據準備
數據查詢,拼寫SQL語句生成DataTable填充到DataSet中,注意表名須要與文件中的表名保持一致。
設置報表樣式,調用報表文件,並將數據填充到報表文件中。
而後編寫一個文件,將解析的結果填充到這個文件中,並將這個文件返回給展現報表的首頁中。
<!DOCTYPE html> <html lang="zh"> <head> <title></title> <meta content="width=device-width, initial-scale=1.0" name="viewport" /> @Html.Raw(ViewBag.CssFile) @WebReportGlobals.Styles() @WebReportGlobals.Scripts() <style> #frbody { overflow: visible !important; } .frtoolbar { height: 70px !important; background-image: none !important; background-color: #fafafa !important; } .refresh_button { background-image: url(../../../../Content/img/刷新.png) !important; background-position: center !important; height: 52px !important; width: 34px !important; } .export_button { background-image: url(../../../../Content/img/保存.png) !important; background-position: center !important; height: 52px !important; width: 30px !important; } .print_button { background-image: url(../../../../Content/img/打印.png) !important; background-position: center !important; height: 52px !important; width: 30px !important; } .zoom_button { background-image: url(../../../../Content/img/縮放.png) !important; background-position: center !important; height: 52px !important; width: 30px !important; } .first_button { background-image: url(../../../../Content/img/首頁.png) !important; background-position: center !important; height: 52px !important; width: 30px !important; } .prev_button { background-image: url(../../../../Content/img/上一頁.png) !important; background-position: center !important; height: 52px !important; width: 41px !important; } .next_button { background-image: url(../../../../Content/img/下一頁.png) !important; background-position: center !important; height: 52px !important; width: 42px !important; } .last_button { background-image: url(../../../../Content/img/尾頁.png) !important; background-position: center !important; height: 52px !important; width: 30px !important; } </style> </head> <body class="fixed-top"> <div id="container" class="row-fluid"> <div id="body"> <div class=""> <div class="row-fluid"> <div class="span12"> <div class="widget box light-grey"> <div class="widget-title"> <div class="tools"> <a href="javascript:;" class="collapse"></a> <a href="#widget-config" data-toggle="modal" class="config"></a> <a href="javascript:;" class="reload"></a> <a href="javascript:;" class="remove"></a> </div> </div> <div class="widget-body"> @ViewBag.WebReport.GetHtml() </div> </span> </div> </div> </div> </div> </div> </div> </div> <script type="text/javascript"> </script> </body> </html>
至此,工做完成。