跳到主要内容

子报表嵌套子报表

概述

子报表嵌套子报表:主表的一个字段和子表的一个字段相关联,子表的一个字段和下一级子表的一个字段相关联。

应用场景

如下图所示,简单展示数据

image
Preview

示例说明

数据准备

在数据面板中添加数据集,可选择Json数据集和API服务数据集。Json数据集输入如下图所示:

"Customer":[
{"CustomerID":"ALFKI","CompanyName":"三川实业有限公司","ContactName":"刘小姐","ContactTitle":"销售代表","Address":"大崇明路 50 号","City":"天津","Region":"华北","PostalCode":"343567","Country":"中国","Phone":"(030) 30074321","Fax":"(030) 30765452"},
{"CustomerID":"ANATR","CompanyName":"东南实业","ContactName":"王先生","ContactTitle":"物主","Address":"承德西路 80 号","City":"天津","Region":"华北","PostalCode":"234575","Country":"中国","Phone":"(030) 35554729","Fax":"(030) 35553744"},
{"CustomerID":"ANTON","CompanyName":"坦森行贸易","ContactName":"王炫皓","ContactTitle":"物主","Address":"黄台北路 780 号","City":"石家庄","Region":"华北","PostalCode":"985060","Country":"中国","Phone":"(0321) 5553932"},
{"CustomerID":"AROUT","CompanyName":"国顶有限公司","ContactName":"方先生","ContactTitle":"销售代表","Address":"天府东街 30 号","City":"深圳","Region":"华南","PostalCode":"890879","Country":"中国","Phone":"(0571) 45557788","Fax":"(0571) 45556750"}
]
"Order":[
{"OrderID":10453,"CustomerID":"AROUT","EmployeeID":1,"OrderDate":"1997/2/21 0:00:00","RequiredDate":"1997/3/21 0:00:00","ShippedDate":"1997/2/26 0:00:00","ShipVia":2,"Freight":25.36,"ShipName":"王先生","ShipAddress":"奋进路 374 号","ShipCity":"石家庄","ShipRegion":"华北","ShipPostalCode":"254356","ShipCountry":"中国"},
{"OrderID":10507,"CustomerID":"ANTON","EmployeeID":7,"OrderDate":"1997/4/15 0:00:00","RequiredDate":"1997/5/13 0:00:00","ShippedDate":"1997/4/22 0:00:00","ShipVia":1,"Freight":47.45,"ShipName":"胡先生","ShipAddress":"方园东 37 号","ShipCity":"重庆","ShipRegion":"西南","ShipPostalCode":"547769","ShipCountry":"中国"},
{"OrderID":10535,"CustomerID":"ANTON","EmployeeID":4,"OrderDate":"1997/5/13 0:00:00","RequiredDate":"1997/6/10 0:00:00","ShippedDate":"1997/5/21 0:00:00","ShipVia":1,"Freight":15.64,"ShipName":"胡先生","ShipAddress":"经三纬六路 237 号","ShipCity":"济南","ShipRegion":"华东","ShipPostalCode":"464598","ShipCountry":"中国"},
{"OrderID":10558,"CustomerID":"AROUT","EmployeeID":1,"OrderDate":"1997/6/4 0:00:00","RequiredDate":"1997/7/2 0:00:00","ShippedDate":"1997/6/10 0:00:00","ShipVia":2,"Freight":72.97,"ShipName":"王先生","ShipAddress":"滨东西路 364 号","ShipCity":"厦门","ShipRegion":"华南","ShipPostalCode":"798780","ShipCountry":"中国"},
{"OrderID":10573,"CustomerID":"ANTON","EmployeeID":7,"OrderDate":"1997/6/19 0:00:00","RequiredDate":"1997/7/17 0:00:00","ShippedDate":"1997/6/20 0:00:00","ShipVia":3,"Freight":84.84,"ShipName":"胡先生","ShipAddress":"城东科技园 74 号","ShipCity":"长春","ShipRegion":"东北","ShipPostalCode":"765345","ShipCountry":"中国"},
{"OrderID":10625,"CustomerID":"ANATR","EmployeeID":3,"OrderDate":"1997/8/8 0:00:00","RequiredDate":"1997/9/5 0:00:00","ShippedDate":"1997/8/14 0:00:00","ShipVia":1,"Freight":43.9,"ShipName":"黄小姐","ShipAddress":"津门路 7 号","ShipCity":"秦皇岛","ShipRegion":"华北","ShipPostalCode":"325456","ShipCountry":"中国"},
{"OrderID":10677,"CustomerID":"ANTON","EmployeeID":1,"OrderDate":"1997/9/22 0:00:00","RequiredDate":"1997/10/20 0:00:00","ShippedDate":"1997/9/26 0:00:00","ShipVia":3,"Freight":4.03,"ShipName":"胡先生","ShipAddress":"广联西路 39 号","ShipCity":"天津","ShipRegion":"华北","ShipPostalCode":"356457","ShipCountry":"中国"},
{"OrderID":10682,"CustomerID":"ANTON","EmployeeID":3,"OrderDate":"1997/9/25 0:00:00","RequiredDate":"1997/10/23 0:00:00","ShippedDate":"1997/10/1 0:00:00","ShipVia":2,"Freight":36.13,"ShipName":"胡先生","ShipAddress":"联合北路 44 号","ShipCity":"天津","ShipRegion":"华北","ShipPostalCode":"496809","ShipCountry":"中国"},
{"OrderID":10702,"CustomerID":"ANATR","EmployeeID":1,"OrderDate":"1997/10/13 0:00:00","RequiredDate":"1997/11/24 0:00:00","ShippedDate":"1997/10/21 0:00:00","ShipVia":1,"Freight":23.94,"ShipName":"锺小姐","ShipAddress":"承德路甲 82 号","ShipCity":"天津","ShipRegion":"华北","ShipPostalCode":"876842","ShipCountry":"中国"},
{"OrderID":10707,"CustomerID":"AROUT","EmployeeID":4,"OrderDate":"1997/10/16 0:00:00","RequiredDate":"1997/10/30 0:00:00","ShippedDate":"1997/10/23 0:00:00","ShipVia":3,"Freight":21.74,"ShipName":"王先生","ShipAddress":"望蜀路 384 号","ShipCity":"成都","ShipRegion":"西南","ShipPostalCode":"645767","ShipCountry":"中国"},
{"OrderID":10741,"CustomerID":"AROUT","EmployeeID":4,"OrderDate":"1997/11/14 0:00:00","RequiredDate":"1997/11/28 0:00:00","ShippedDate":"1997/11/18 0:00:00","ShipVia":3,"Freight":10.96,"ShipName":"王先生","ShipAddress":"新碑路 37 号","ShipCity":"秦皇岛","ShipRegion":"华北","ShipPostalCode":"486526","ShipCountry":"中国"},
{"OrderID":10743,"CustomerID":"AROUT","EmployeeID":1,"OrderDate":"1997/11/17 0:00:00","RequiredDate":"1997/12/15 0:00:00","ShippedDate":"1997/11/21 0:00:00","ShipVia":2,"Freight":23.72,"ShipName":"王先生","ShipAddress":"明新路 32 号","ShipCity":"天津","ShipRegion":"华北","ShipPostalCode":"683235","ShipCountry":"中国"},
{"OrderID":10759,"CustomerID":"ANATR","EmployeeID":3,"OrderDate":"1997/11/28 0:00:00","RequiredDate":"1997/12/26 0:00:00","ShippedDate":"1997/12/12 0:00:00","ShipVia":3,"Freight":11.99,"ShipName":"黄小姐","ShipAddress":"海淀区翠微路 238 号","ShipCity":"北京","ShipRegion":"华北","ShipPostalCode":"150216","ShipCountry":"中国"},
{"OrderID":10768,"CustomerID":"AROUT","EmployeeID":3,"OrderDate":"1997/12/8 0:00:00","RequiredDate":"1998/1/5 0:00:00","ShippedDate":"1997/12/15 0:00:00","ShipVia":2,"Freight":146.32,"ShipName":"王先生","ShipAddress":"黄石碑东街 37 号","ShipCity":"张家口","ShipRegion":"华北","ShipPostalCode":"268964","ShipCountry":"中国"},
{"OrderID":10793,"CustomerID":"AROUT","EmployeeID":3,"OrderDate":"1997/12/24 0:00:00","RequiredDate":"1998/1/21 0:00:00","ShippedDate":"1998/1/8 0:00:00","ShipVia":3,"Freight":4.52,"ShipName":"王先生","ShipAddress":"白土路 54 号","ShipCity":"天津","ShipRegion":"华北","ShipPostalCode":"564270","ShipCountry":"中国"}
]
"OrderDetail":[
{"OrderID":10453,"ProductID":70,"UnitPrice":12,"Quantity":25,"Discount":0.1},
{"OrderID":10453,"ProductID":48,"UnitPrice":10.2,"Quantity":15,"Discount":0.1},
{"OrderID":10507,"ProductID":43,"UnitPrice":46,"Quantity":15,"Discount":0.15},
{"OrderID":10507,"ProductID":48,"UnitPrice":12.75,"Quantity":15,"Discount":0.15},
{"OrderID":10535,"ProductID":11,"UnitPrice":21,"Quantity":50,"Discount":0.1},
{"OrderID":10535,"ProductID":40,"UnitPrice":18.4,"Quantity":10,"Discount":0.1},
{"OrderID":10535,"ProductID":57,"UnitPrice":19.5,"Quantity":5,"Discount":0.1},
{"OrderID":10535,"ProductID":59,"UnitPrice":55,"Quantity":15,"Discount":0.1},
{"OrderID":10558,"ProductID":47,"UnitPrice":9.5,"Quantity":25,"Discount":0},
{"OrderID":10558,"ProductID":73,"UnitPrice":15,"Quantity":3,"Discount":0},
{"OrderID":10558,"ProductID":53,"UnitPrice":32.8,"Quantity":18,"Discount":0},
{"OrderID":10558,"ProductID":51,"UnitPrice":53,"Quantity":20,"Discount":0},
{"OrderID":10558,"ProductID":52,"UnitPrice":7,"Quantity":30,"Discount":0},
{"OrderID":10573,"ProductID":17,"UnitPrice":39,"Quantity":18,"Discount":0},
{"OrderID":10573,"ProductID":34,"UnitPrice":14,"Quantity":40,"Discount":0},
{"OrderID":10573,"ProductID":53,"UnitPrice":32.8,"Quantity":25,"Discount":0},
{"OrderID":10625,"ProductID":42,"UnitPrice":14,"Quantity":5,"Discount":0},
{"OrderID":10625,"ProductID":14,"UnitPrice":23.25,"Quantity":3,"Discount":0},
{"OrderID":10625,"ProductID":60,"UnitPrice":34,"Quantity":10,"Discount":0},
{"OrderID":10677,"ProductID":33,"UnitPrice":2.5,"Quantity":8,"Discount":0.15},
{"OrderID":10677,"ProductID":26,"UnitPrice":31.23,"Quantity":30,"Discount":0.15},
{"OrderID":10682,"ProductID":33,"UnitPrice":2.5,"Quantity":30,"Discount":0},
{"OrderID":10682,"ProductID":66,"UnitPrice":17,"Quantity":4,"Discount":0},
{"OrderID":10682,"ProductID":75,"UnitPrice":7.75,"Quantity":30,"Discount":0},
{"OrderID":10702,"ProductID":3,"UnitPrice":10,"Quantity":6,"Discount":0},
{"OrderID":10702,"ProductID":76,"UnitPrice":18,"Quantity":15,"Discount":0},
{"OrderID":10707,"ProductID":57,"UnitPrice":19.5,"Quantity":40,"Discount":0},
{"OrderID":10707,"ProductID":70,"UnitPrice":15,"Quantity":28,"Discount":0.15},
{"OrderID":10707,"ProductID":55,"UnitPrice":24,"Quantity":21,"Discount":0},
{"OrderID":10741,"ProductID":2,"UnitPrice":19,"Quantity":15,"Discount":0.2},
{"OrderID":10743,"ProductID":46,"UnitPrice":12,"Quantity":28,"Discount":0.05},
{"OrderID":10759,"ProductID":32,"UnitPrice":32,"Quantity":10,"Discount":0},
{"OrderID":10768,"ProductID":22,"UnitPrice":21,"Quantity":4,"Discount":0},
{"OrderID":10768,"ProductID":31,"UnitPrice":12.5,"Quantity":50,"Discount":0},
{"OrderID":10768,"ProductID":60,"UnitPrice":34,"Quantity":15,"Discount":0},
{"OrderID":10768,"ProductID":71,"UnitPrice":21.5,"Quantity":12,"Discount":0},
{"OrderID":10793,"ProductID":52,"UnitPrice":7,"Quantity":8,"Discount":0},
{"OrderID":10793,"ProductID":41,"UnitPrice":9.65,"Quantity":14,"Discount":0}
]

报表设计

将数据字段拖入相对应的位置,并设置为分组(不合并单元格)以及不扩展。
选中A1-D10,点击上方工具栏-添加分组。
将A10-D10单元格合并,并设置为占位。

如下图所示

image
Preview

效果预览

子报表嵌套子报表.json

image
Preview