彩票走势图

DevExpress开发教程之报表打印设计应用篇

原创|其它|编辑:郝浩|2012-10-12 17:24:39.000|阅读 1760 次

概述:这个章节内容详细说明《DevExpress开发教程之报表打印设计实现篇》中的关键代码部分、简单的设计和打印应用。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

这个章节内容详细说明《DevExpress开发教程之报表打印设计实现篇》中的关键代码部分、简单的设计和打印应用。

 1、DevExpress中可以通过report.RunDesignerDialog或者report.RunDesigner来设计报表,这里没有使用这两个方法来实现报表设计功能,而是使用第一章中的自定义的DesignReportForm来实现(实际上相同,但自定义可以控制其他如根据权限显示等内容)。

 2、DesignReportForm非常简单,就是把DesignReportControl,DesignToolBar和DesignFormattingToolBar拼凑在一起,它们共同关联designReportControl1.DesignPanel。

 3、现在设计一个简单的DataSet,内容如下:

DataSet ds = new DataSet("DeliveryDataSet");
            DataTable dtDelivery= new DataTable("Delivery");
            {
                dtDelivery.Columns.Add("BillId", typeof(string));
                dtDelivery.Columns.Add("ManualId", typeof(string));
                dtDelivery.Columns.Add("BillDate", typeof(DateTime));
                dtDelivery.Columns.Add("CustomerId", typeof(string));
                dtDelivery.Columns.Add("WarehouseId", typeof(string));
                dtDelivery.Columns.Add("Maker", typeof(string));
                dtDelivery.Columns.Add("Remark", typeof(string));
                {
                    DataRow row = dtDelivery.NewRow();
                    row["BillId"] = "IGZ0000002";
                    row["ManualId"] = "Kingmond.Demo";
                    row["BillDate"] = DateTime.Today;
                    row["CustomerId"] = "Regent";
                    row["WarehouseId"] = "MyStore";
                    row["Maker"] = "kevin";
                    row["Remark"] = "Demo a report.";
                    dtDelivery.Rows.Add(row);
                }
            }

            DataTable dtDeliveryGoods = new DataTable("DeliveryGoods");
            {
                dtDeliveryGoods.Columns.Add("BillId", typeof(string));
                dtDeliveryGoods.Columns.Add("BillGoodsId", typeof(string));
                dtDeliveryGoods.Columns.Add("GoodsId", typeof(string));
                dtDeliveryGoods.Columns.Add("Quantity", typeof(int));
                {
                    DataRow row = dtDeliveryGoods.NewRow();
                    row["BillId"] = "IGZ0000002";
                    row["BillGoodsId"] = "IGZ0000002001";
                    row["GoodsId"] = "R001";
                    row["Quantity"] = 23;
                    dtDeliveryGoods.Rows.Add(row);
                }
                {
                    DataRow row = dtDeliveryGoods.NewRow();
                    row["BillId"] = "IGZ0000002";
                    row["BillGoodsId"] = "IGZ0000002002";
                    row["GoodsId"] = "R002";
                    row["Quantity"] = 36;
                    dtDeliveryGoods.Rows.Add(row);
                }
            }
            DataTable dtDeliveryDetail = new DataTable("DeliveryDetail");
            {
                dtDeliveryDetail.Columns.Add("AutoId", typeof(int));
                dtDeliveryDetail.Columns.Add("BillGoodsId", typeof(string));
                dtDeliveryDetail.Columns.Add("ColorId", typeof(string));
                dtDeliveryDetail.Columns.Add("GoodsLong", typeof(string));
                dtDeliveryDetail.Columns.Add("S1", typeof(int));
                dtDeliveryDetail.Columns.Add("S2", typeof(int));
                dtDeliveryDetail.Columns.Add("S3", typeof(int));
                {
                    DataRow row = dtDeliveryDetail.NewRow();
                    row["AutoId"] = 1;
                    row["BillGoodsId"] = "IGZ0000002001";
                    row["ColorId"] = "RED";
                    row["GoodsLong"] = "0";
                    row["S1"] = 7;
                    row["S3"] = 11;
                    dtDeliveryDetail.Rows.Add(row);
                }
                {
                    DataRow row = dtDeliveryDetail.NewRow();
                    row["AutoId"] = 2;
                    row["BillGoodsId"] = "IGZ0000002001";
                    row["ColorId"] = "WHT";
                    row["GoodsLong"] = "0";
                    row["S1"] = 2;
                    row["S2"] = 3;
                    dtDeliveryDetail.Rows.Add(row);
                }

                {
                    DataRow row = dtDeliveryDetail.NewRow();
                    row["AutoId"] = 3;
                    row["BillGoodsId"] = "IGZ0000002002";
                    row["ColorId"] = "RED";
                    row["GoodsLong"] = "0";
                    row["S1"] = 1;
                    row["S2"] = 7;
                    dtDeliveryDetail.Rows.Add(row);
                }
                {
                    DataRow row = dtDeliveryDetail.NewRow();
                    row["AutoId"] = 4;
                    row["BillGoodsId"] = "IGZ0000002002";
                    row["ColorId"] = "BLK";
                    row["GoodsLong"] = "0";
                    row["S1"] = 20;
                    row["S2"] = 8;
                    dtDeliveryDetail.Rows.Add(row);
                }
            }
            ds.Tables.Add(dtDelivery);
            ds.Tables.Add(dtDeliveryGoods);
            ds.Tables.Add(dtDeliveryDetail);
            //设置表之间的关系
            ds.Relations.Add("Delivery_DeliveryGoods", dtDelivery.Columns["BillId"], dtDeliveryGoods.Columns["BillId"]);            
            ds.Relations.Add("DeliveryGoods_DeliveryDetail", dtDeliveryGoods.Columns["BillGoodsId"], dtDeliveryDetail.Columns["BillGoodsId"]);

4、DataSet通过方法WriteXmlSchema(@"c:\temp\delivery.xml");可以很容易得到DataSet的Schema文件。

5、 设计delivery 报表格式,通过

 ReportUtil.DesignReport (@"c:\temp\delivery.repx",@"c:\temp\delivery.xml")可以设计已经存在的格式文件.

6、设计结果参考图片:

DevExpress开发教程之报表打印设计应用篇

7、预览结果参考图片:

DevExpress开发教程之报表打印设计应用篇



标签:DevExpress报表

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn

文章转载自:博客园

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP