FastReport报表金额数字转大写问题

2023-03-08,,

在使用FastReport报表打印的时候涉及到财务结算金额时,会用到大写,系统保存的都为数字,将数字转换为大写没有默认的系统内置函数,经过查阅资料,可通过对FastReport的页面设计代码修改实现:c#代码

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing;
using System.Data;
using FastReport;
using FastReport.Data;
using FastReport.Dialog;
using FastReport.Barcode;
using FastReport.Table;
using FastReport.Utils;
using System.Text.RegularExpressions; //首先引入命名空间

namespace FastReport
{
public class ReportScript
{
private string DaXie(decimal money)
{
string s =money.ToString("#L#E#D#C#K#E#D#C#J#E#D#C#I#E#D#C#H#E#D#C#G#E#D#C#F#E#D#C#.0B0A");
string d =Regex.Replace(s,@"((?<=-|^)[^1-9]*)|((?'z'0)[0A-E]*((?=[1-9])|(?'-z'(?=[F-L\.]|$))))|((?'b'[F-L])(?'z'0)[0A-L]*((?=[1-9])|(?'-z'(?=[\.]|$))))","${b}${z}");
return Regex.Replace(d,".",delegate(Match m){return"负元空零壹贰叁肆伍陆柒捌玖空空空空空空空分角拾佰仟万億兆京垓秭穰"[m.Value[0]-'-'].ToString();});
}
}
}

在使用的时候,报表绑定数据时 类似用 [DaXie([VW_TB_JieSuanDan.JieSuanMoney])] 元

效果如下:

FastReport报表金额数字转大写问题的相关教程结束。

《FastReport报表金额数字转大写问题.doc》

下载本文的Word格式文档,以方便收藏与打印。