FastReport使用教程

FastReport使用教程FastReport使用心得一、准备1、这次开发使用的是FastReport桌面版(FastReport.NetVersion201731.16Demo)2、引用类库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>

    至此,工作完成。

  

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/155677.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号