FastReport使用教程


FastReport使用心得

一、准備

  1、這次開發使用的是FastReport桌面版(FastReport.Net Version 201731.16 Demo)

  2、引用類庫FastReport.dll、FastReport.Web.dll

二、桌面版制作報表

  1、添加數據源

    Report------Add Data Source------

    連接數據庫,測試連接成功,選取數據表,字段自動帶出到界面

    如果數據源中增加了額外的數據字段,需要注意字段的屬性需要保持一致,Calculated屬性設置為False

  2、畫報表頁面

    使用table,直接拖拽數據字段至指定位置即可

  3、報表文件的處理

    FastReport文件本質是XML形式的鍵值對,

    <Dirctionary></Dirctionary>標簽下的<MsSqlDataConnection></MsSqlDataConnection>刪除,注意是刪除標簽對。這里刪除的原因是,我們是使用的是桌面版FastReport制作報表,但是是用網頁版來調用文件,網頁版只傳DataSource給FastReport文件。

    <Dirctionary></Dirctionary>標簽下的<TableDataSource>的屬性需要調整,除了Name、TableName需要與提供的數據源的表名XXX對應外,還需要增加一個屬性ReferenceName,值為XXX.XXX。

 三、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>

    至此,工作完成。

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM