先看看打印入库单的效果图,看如下:

客户要求合计一行,要求大写中文数字。xtrareport报表是如何做出以上图的效果呢?因为是要把数字转成大写中文数字,得先准备数字转大写中文数字的函数。因网上有很多方法,我这里就不上传代码了。这里只说一下xtrareport报表创建以上收货单报表大写数字操作。新建一个xtrareport报表,设置好收货单报表格式。使用的是运行时绑定数据,以下是源码:

 1 public enterstockrpt(dataset ds)
 2         {
 3             initializecomponent();
 4             //绑定主表 
 5             datasource = ds;
 6             datamember = "parent";
 7             xlsuppliername.databindings.add("text", ds, "suppliername");
 8             xlenterstockid.databindings.add("text", ds, "enterstockid");            
 9             xlenterdate.databindings.add("text", ds, "enterdate","{0:d}");
10             //绑定从表 
11             detailreport.datasource = ds;
12             detailreport.datamember = "r1";
13             xtproductid.databindings.add("text", ds, "r1.productid");
14             xtproductname.databindings.add("text", ds, "r1.productname");
15             xtproductunit.databindings.add("text", ds, "r1.productunit");
16             xtquantity.databindings.add("text", ds, "r1.quantity");
17             xtprice.databindings.add("text", ds, "r1.price");
18             xtamountmoney.databindings.add("text", ds, "r1.amountmoney");
19             //合计
20             xrtablecellgroupsumaccount.databindings.add("text", ds, "r1.amountmoney");
21             xrtablecellgroupsumaccount.summary = new xrsummary(summaryrunning.report, summaryfunc.sum, string.empty);
22             //数字转中文大写数字
23             xrtablecellgroupsumaccountchina.databindings.add("text", ds, "enterstockmoneys");
24             totalmoney = convert.todecimal(getcurrentcolumnvalue("enterstockmoneys"));
25         }

假如大写后面的表格名称是:xrtablecellgroupsumaccountchina。添加summarygetresult的事件。以下是源码:

private void xrtablecellgroupsumaccountchina_summarygetresult(object sender, summarygetresulteventargs e)
        {
            //这里的全局函数turn_moneytobig(),用作将金额变成中文大写
            e.result = cmycurd(totalmoney);
            //e.handled=true;这一行必须
            e.handled = true;
        }

做完以上操作,如果你现在就测试预览。数字一定不会转成大写数字。原因很简单,xrtablecellgroupsumaccountchina的属性summary一定要修改一下。如下图: