一款封装好的动态自动绘制报表类-转贴
针对需要大量报表的项目来说,一个个绘制报表是一件非常痛苦的事情,而因为项目的更换表格的部分信息变化又要重新绘制更是痛苦不堪,有没有方法让XtraReports动态自动生成报表,形成便于维护的报表模板呢?大家请看(转自:http://www.cnblogs.com/pains/archive/2012/06/14/2549228.html)
来看看报表显示结果
http://pic002.cnblogs.com/images/2012/25733/2012061415242450.jpg
来看看报表的定义文件
/// <summary>
/// 报表布局数组
/// </summary>
private void makeLayoutString()
{
// 报表主要布局
ReportLayout = new string[][][]
{
// 报表头标题布局
new string[][]
{
// 报表标题
new string[] { "××至××西线高速公路","房建工程清单支付报表" },
// 报表其它头标题
new string[] { "1", "承包单位", "4" },
new string[] { "2", "合同段", "2" },
new string[] { "3", "填报日期", "2" },
new string[] { "4", "监理单位", "4" },
new string[] { "5", "期号", "2" } ,
new string[] { "6", "截止日期","2"}
},
// 报表明细布局
new string[][]
{
new string[] { "1", "项目编号", "89" ,"22"},
new string[] { "2", "项目名称", "200","6" },
new string[] { "3", "c单位", "20" },
new string[] { "4", "r合同数量", "100" },
new string[] { "5", "r单价", "30" },
new string[] { "6", "r变更后数量", "100" },
new string[] { "7", "r本期末完成数量", "100" },
new string[] { "8", "r本期末完成金额","100"},
new string[] { "9", "r上期末完成数量", "100" },
new string[] { "10", "r上期末完成金额", "100" },
new string[] { "11", "r本期完成数量", "70" },
new string[] { "12", "r本期完成金额", "80" },
},
new string[][]
{
new string[]{"1","承包人","1"},
new string[]{"2","监理处专业工程师","1"},
new string[]{"3","监理处计量工程师","1"},
new string[]{"4","高级驻地","1"},
new string[]{"5","计划部专业工程师","1"},
new string[]{"6","合约部计量工程师","1"}
}
};
// 报表统计布局(未用)
mTotalLayout = new string[][]
{
new string[]{"小计","289"},
new string[]{"","20"},
new string[]{"","100"},
new string[]{"","30"},
new string[]{"","100"},
new string[]{"","100"},
new string[]{"8","100",DevExpress.XtraReports.UI.SummaryFunc.Sum.ToString()},
new string[]{"","100"},
new string[]{"10","100",DevExpress.XtraReports.UI.SummaryFunc.Sum.ToString()},
new string[]{"","70"},
new string[]{"12","80",DevExpress.XtraReports.UI.SummaryFunc.Sum.ToString()},
};
// 报表分组布局
mGroupLayout = new string[]
{
"1","dfasdf"
};
//报表明细列头布局
mdetailHeadLayout = new string[][]
{
new string[] { "项目编号", "89" },
new string[] { "项目名称", "200" },
new string[] { "单位", "20" },
new string[] { "合同数量", "230" },
new string[] { "到本期末完成", "200" },
new string[] { "到上期末完成", "200" },
new string[] { "本期完成", "150" },
new string[] { "", "89" },
new string[] { "", "200" },
new string[] { "", "20" },
new string[] { "原合同数量", "100" },
new string[] { "单价", "30" },
new string[] { "变更后数量", "100" },
new string[] { "数量", "100" },
new string[] { "金额(元)","100"},
new string[] { "数量", "100" },
new string[] { "金额(元)", "100" },
new string[] { "数量", "70" },
new string[] { "金额(元)", "80" }
};
}
这样就形成了模板文件,对于移植更改维护相当的方便。那么对于不规则类的表格可不可以做呢?大家请看
http://pic002.cnblogs.com/images/2012/25733/2012061415314323.jpghttp://pic002.cnblogs.com/images/2012/25733/2012061415315442.jpg
对于项目中一次打印审批数量非常的表格,也可以加上条形码,配上扫描设备就便于查找审批了
http://images.5d6d.net/dz7/templates/default/attachimg.gif http://ii.a.5d6d.com/userdirs/b/5/smartsoft/attachments/month_1206/12061517210aa2e08be47dcc6e.jpg
不错不错,感谢楼主分享 不错,不过我还是用APOSE CELL来做,因为国产报表实在画起来累,让客户做好模板,我就填数据了 回复,很给力,学习一下 好像是需要购买的 做个系统正需要这个表格,不错,支持! 没下载啊好像是收费的 拯救了人类啊。。。 tanqimin 发表于 2013-6-21 23:43
拯救了人类啊。。。
可惜了,是要收费的,唉…… 我现在用Grid++Report,等卖软件赚了钱就跟他买正式版,毕竟是国货。完全免费。呵呵,我是不是有广告嫌疑呀。先声明,不是广告哦。 大哥你这也叫动态啊。。。 我觉得真真的办法是把模板和表格分离。 这样一个查询表格的数据源可以对应多个报表模板,那么无论客户需求怎么变只需要稍稍修改下数据源或者模板就可以了。
页:
[1]