带小计 ,分组的 都给自动画出来了.不得不说牛啊,要自己拼出来上边的样子,估计头都要大了.本来想自己堆出来, 要很熟悉画行 ,单元格 ....最后找到了以往的例子. 复盘了一次,又进一步
感慨交叉报表真的太方便了.
交叉表设计参考地址
https://docs.devexpress.com/XtraReports/4226/create-reports/create-a-cross-tab-report
数据源为对象的那个类的写法参考地址(大多数例程数据源是数据库.对于动态生成报表,比如带查询功能页面的生成报表要求是不友好的.)
https://docs.devexpress.com/XtraReports/400316/create-reports/create-a-vertical-report
using System; using System.Collections.Generic; namespace XtraReportsDemos.ProfitAndLossReport { public class Data { static List<Data> currentData; public DateTime Month { get; set; } public decimal ConstructionIncome { get; set; } public decimal SalesIncome { get; set; } public decimal CostOfGoodsSold { get; set; } public decimal JobExpenses { get; set; } public decimal Automobile { get; set; } public decimal BankServiceCharges { get; set; } public decimal Insurance { get; set; } public decimal PayrollExpenses { get; set; } public decimal Repairs { get; set; } public decimal ToolsAndMachinery { get; set; } public static List<Data> GetData() { if(currentData == null) currentData = CreateData(); return currentData; } static List<Data> CreateData() { List<Data> result = new List<Data>(); for(int i = 1; i <= 12; i++) result.Add(CreateItem(2018, i)); return result; } static Data CreateItem(int year, int month) { Random rnd = new Random(month); return new Data() { Month = new DateTime(year, month, DateTime.DaysInMonth(year, month)), ConstructionIncome = rnd.Next(75000, 125000) + (decimal)rnd.Next(100) / 100, SalesIncome = rnd.Next(0, 1000), CostOfGoodsSold = rnd.Next(0, 3500) + (decimal)rnd.Next(100) / 100, JobExpenses = rnd.Next(5000, 35000) + (decimal)rnd.Next(100) / 100, Automobile = rnd.Next(300, 900) + (decimal)rnd.Next(100) / 100, BankServiceCharges = rnd.Next(10, 80), Insurance = rnd.Next(1000, 5000), PayrollExpenses = rnd.Next(9000, 18000), Repairs = rnd.Next(0, 400), ToolsAndMachinery = rnd.Next(0, 1000), }; } } }
在设计交叉表的时候 要道道getdata相关字样的那个页面
交叉报表 很适合有小计 分组的 需求
技术交流qq群:143280841