惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
News and Events Feed by Topic
S
SegmentFault 最新的问题
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Last Week in AI
Last Week in AI
Jina AI
Jina AI
H
Help Net Security
C
Check Point Blog
aimingoo的专栏
aimingoo的专栏
MyScale Blog
MyScale Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Vercel News
Vercel News
L
LangChain Blog
Recorded Future
Recorded Future
F
Full Disclosure
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
GbyAI
GbyAI
B
Blog RSS Feed
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
M
MIT News - Artificial intelligence
爱范儿
爱范儿
V
V2EX
Microsoft Azure Blog
Microsoft Azure Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Y
Y Combinator Blog
B
Blog
WordPress大学
WordPress大学
Blog — PlanetScale
Blog — PlanetScale
W
WeLiveSecurity
MongoDB | Blog
MongoDB | Blog
Cloudbric
Cloudbric
N
News and Events Feed by Topic
The Cloudflare Blog
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
有赞技术团队
有赞技术团队
D
DataBreaches.Net
博客园 - 【当耐特】
T
Troy Hunt's Blog
V
Visual Studio Blog
V2EX - 技术
V2EX - 技术
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 司徒正美
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google Online Security Blog
Google Online Security Blog
The GitHub Blog
The GitHub Blog

博客园 - 老D

.NET Memcached Client 扩展获取所有缓存Key SQL Server 2005 中新CTE语法 递归性能测试 合并 GridView 的单元格 连接远程服务器共享 在代码中恢复sql server 数据库 - 老D 获取同一网段内的SQL SERVER实例 C#动态加载DLL Asp.net 文件下载 在网页处理按键事件 - 老D - 博客园 SQL语句导入导出大全 跨应用程序进行 Forms 身份验证 GridView导出Excel ASP.NET数据库连接字符串的加密与解密 ASP.NET中GridView动态绑定数据实现编辑更新 ASp.NET 2.0中Page事件的执行顺序 批量insert数据 简繁转换 ASP.NET应用程序开发 经典算法-C#四种排序算法
在Crystal Report中将数字转为英文
老D · 2008-09-02 · via 博客园 - 老D

     最近一个项目中需要水晶报表打印Invoice,在汇总金额的同时要把金额转换为英文表示,最开始的时候客户需求是只在Invoice最后一页总汇总的时候才需要显示英文,所以当被直接在.net中转好英文,然后再在数据源xsd设置多一个英文字段传到报表中。使用一段时间后客户要求每一页Invoice需要汇总英文,麻烦来了,如果要传参数法,将不能确定水晶报表分几页也没法传不固定参数,于是直接在水晶报表中写了转换方法,需要这样要求的朋友可以自己改改

1.在水晶报表中建立一个转换方法 DecimalToWords

Function (numbervar decimals)
    local stringVar array _smallNumbers := ["ZERO",   "ONE",   "TWO",   "THREE",   "FOUR",   "FIVE",   "SIX",   "SEVEN",   "EIGHT",
        "NINE",   "TEN",   "ELEVEN",   "TWELVE",   "THIRTEEN",   "FOURTEEN",   "FIFTEEN",
        "SIXTEEN",   "SEVENTEEN",   "EIGHTEEN",   "NINETEEN"];
    local stringVar array _tens := ["",   "",   "TWENTY",   "THIRTY",   "FORTY",   "FIFTY",   "SIXTY",   "SEVENTY",   "EIGHTY", "NINETY"];
    local stringVar array _scaleNumers := ["", "THOUSAND", "MILLION", "BILLION" ];
    stringVar combined := _smallNumbers[1];
    if decimals <> 0 then
    (
        numberVar i := 1;
        numberVar array digitGroups := [0,0,0,0];

        for i := 1  to 4 step 1  do
        (
            digitGroups[i] := decimals mod 1000;
            decimals := Int(decimals / 1000);
        );
        stringVar array groupText := ["","","",""];
        for i:=1 to 4 step 1 do
        (
            numberVar hundreds := Int(digitGroups[i] / 100);
            numberVar tensUnits := digitGroups[i] mod 100;
            if hundreds <> 0 then
            (
                groupText[i] := groupText[i] + _smallNumbers[hundreds+1] + " HUNDRED";
                if tensUnits <> 0 then
                    groupText[i] := groupText[i] + " ";
            );         
            numberVar tens := Int(tensUnits / 10);
            numberVar units := tensUnits mod 10;
            if tens >= 2 then
            (
                groupText[i] := groupText[i] + _tens[tens+1];
                if units <> 0 then
                    groupText[i] := groupText[i] + "-" + _smallNumbers[units+1];
            )
            else if tensUnits <> 0 then
                groupText[i] := groupText[i] + _smallNumbers[tensUnits +1]
        );
        combined := groupText[1];
        for i:=2 to 4 step 1 do
        (
            if digitGroups[i] <> 0 then
            (
                stringVar prefix := groupText[i] + " " + _scaleNumers[i];
                if Length(combined) <> 0 then
                    prefix := prefix+ " ";
                combined := prefix + combined;
             );
        );
    );
    combined;

2.然后在水晶报表中建一个 公式字段 TotalEg

     DecimalToWords ({#Total})  //其中Total是个汇总字段

3.把上一步建的公式字段TotalEg拖到报表需要的位置