- 浏览: 220993 次
- 性别:
- 来自: 沈阳
文章分类
- 全部博客 (105)
- java (30)
- linux unix (19)
- 版本控制 (15)
- ajax (2)
- 开发工具及辅助工具 (3)
- database (2)
- flex (10)
- 其它 (2)
- windows (1)
- 开源企业应用 (6)
- 开源erp (4)
- 开源cms (0)
- 开源门户 (0)
- php (1)
- ofbiz&opentaps (4)
- 运维管理 (0)
- MOQUI (3)
- linux unix mysql (0)
- mysql (2)
- hadoop (3)
- android (0)
- 微信公众号 (1)
- java cassandra nosql (0)
- Nosql (1)
- socket (1)
- tcp (1)
- udp (1)
- 十六进制 (1)
- ofbiz (1)
- docker (1)
- 虚拟化 (0)
- 分布式 (0)
最新评论
-
w87848608:
用phpunit --coverage-html命令一样出现了 ...
关于phpunit与Selenium取coverage的配置(原创) -
surpass_li:
好久没来这了,不好意思,你参照Deploying OFBiz ...
ofibz10.04部署到 jboss5.1.0成功 -
tide2046:
求部署文档。谢谢。
ofibz10.04部署到 jboss5.1.0成功 -
Romotc:
征文 +1,1楼的方法还是有点问题。
eclipse编译时过滤SVN版本控制信息方法 -
我改名了:
谢谢,收 藏 了,备用。
Java获取客户端真实IP地址的两种方法(转)
摘自 http://www.blogjava.net/hispark/archive/2008/11/19/241321.html
我们在制作单证或报表时,客户经常要我们把最后的合计数转写中文大写金额。这个需求很合理,但感觉并不容易实现,如何在JasperReport中加入大写金额的实现呢?提供一种实现的方法给大家参考。
实现思路:
在报表执行过程中使用scirptlet将存放着数字金额的变量读出转换成大写金额字符串后放入大写金额变量中。报表即可象显示普通字符变量一样显示大写金额。
TransChineseMoneyScriptlet.java代码
1
/** */
/**
2 * 大写金额转换Scriptlet类
3 *
4 * @author Spark (Email: spark.unt@gmail.com)
5 */
6 public class TransChineseMoneyScriptlet extends JRDefaultScriptlet {
7 /**/ /*
8 * 默认构造方法
9 */
10 public TransChineseMoneyScriptlet() {
11
12 }
13
14 /** */ /**
15 * 获得金额的汉字大写格式 <br>
16 * @param money 小写金额字符串
17 * @return 大写的汉字金额
18 */
19 public static String getChineseMoney(String money) {
20 String text = transChineseMoney1(money) + transChineseMoney2(money);
21 Pattern p = Pattern.compile( " 零分 " , Pattern.CASE_INSENSITIVE);
22 Matcher m = p.matcher(text);
23 text = m.replaceAll( "" );
24 return text;
25 }
26
27 /** */ /**
28 * 截得输入金额的整数部分,并将其转换成中文大写的格式 <br>
29 * <br>
30 * 其他描述:输入数字超过接受范围时拒绝转换并退出。<br>
31 * @param 传递参数字符串S 参数描述
32 * @return 返回转换后的字符串
33 */
34 public static String transChineseMoney1(String s) {
35 String ss = s;
36 String tmpnewchar = "" ;
37 String[] part = ss.split( " \\. " );
38
39 if (part[ 0 ].length() > 10 ) {
40 // 超出可转换位数
41 return "" ;
42 }
43 for ( int i = 0 ; i < part[ 0 ].length(); i ++ ) {
44 char perchar = part[ 0 ].charAt(i);
45 if (perchar == ' 0 ' )
46 tmpnewchar = tmpnewchar + " 零 " ;
47 if (perchar == ' 1 ' )
48 tmpnewchar = tmpnewchar + " 壹 " ;
49 if (perchar == ' 2 ' )
50 tmpnewchar = tmpnewchar + " 贰 " ;
51 if (perchar == ' 3 ' )
52 tmpnewchar = tmpnewchar + " 叁 " ;
53 if (perchar == ' 4 ' )
54 tmpnewchar = tmpnewchar + " 肆 " ;
55 if (perchar == ' 5 ' )
56 tmpnewchar = tmpnewchar + " 伍 " ;
57 if (perchar == ' 6 ' )
58 tmpnewchar = tmpnewchar + " 陆 " ;
59 if (perchar == ' 7 ' )
60 tmpnewchar = tmpnewchar + " 柒 " ;
61 if (perchar == ' 8 ' )
62 tmpnewchar = tmpnewchar + " 捌 " ;
63 if (perchar == ' 9 ' )
64 tmpnewchar = tmpnewchar + " 玖 " ;
65
66 int j = part[ 0 ].length() - i - 1 ;
67 if (j == 0 )
68 tmpnewchar = tmpnewchar + " 圆 " ;
69 if (j == 1 && perchar != 0 )
70 tmpnewchar = tmpnewchar + " 拾 " ;
71 if (j == 2 && perchar != 0 )
72 tmpnewchar = tmpnewchar + " 佰 " ;
73 if (j == 3 && perchar != 0 )
74 tmpnewchar = tmpnewchar + " 仟 " ;
75 if (j == 4 && perchar != 0 )
76 tmpnewchar = tmpnewchar + " 万 " ;
77 if (j == 5 && perchar != 0 )
78 tmpnewchar = tmpnewchar + " 拾 " ;
79 if (j == 6 && perchar != 0 )
80 tmpnewchar = tmpnewchar + " 佰 " ;
81 if (j == 7 && perchar != 0 )
82 tmpnewchar = tmpnewchar + " 仟 " ;
83 if (j == 8 && perchar != 0 )
84 tmpnewchar = tmpnewchar + " 亿 " ;
85 if (j == 9 && perchar != 0 )
86 tmpnewchar = tmpnewchar + " 拾 " ;
87 }
88 return tmpnewchar;
89 }
90
91 /** */ /**
92 * 截得输入金额的小数部分,并将其转换成中文大写的格式 <br>
93 * <br>
94 * 其他描述:小数部分超过两位时系统自动截断。<br>
95 *
96 * @param 传递参数字符串
97 *
98 * @return 返回转换后的字符串
99 */
100 public static String transChineseMoney2(String s) {
101 String ss = s;
102 String tmpnewchar1 = "" ;
103 String[] part = ss.split( " \\. " );
104
105 if (ss.indexOf( " . " ) != - 1 ) {
106 if (part[ 1 ].length() > 2 ) {
107 // MessageDialog.openInformation(null,"提示","小数点之后只能保留两位,系统将自动截段");
108 part[ 1 ] = part[ 1 ].substring( 0 , 2 );
109 }
110 for ( int i = 0 ; i < part[ 1 ].length(); i ++ ) {
111 char perchar = part[ 1 ].charAt(i);
112 // System.out.println(perchar);
113 if (perchar == ' 0 ' )
114 tmpnewchar1 = tmpnewchar1 + " 零 " ;
115 if (perchar == ' 1 ' )
116 tmpnewchar1 = tmpnewchar1 + " 壹 " ;
117 if (perchar == ' 2 ' )
118 tmpnewchar1 = tmpnewchar1 + " 贰 " ;
119 if (perchar == ' 3 ' )
120 tmpnewchar1 = tmpnewchar1 + " 叁 " ;
121 if (perchar == ' 4 ' )
122 tmpnewchar1 = tmpnewchar1 + " 肆 " ;
123 if (perchar == ' 5 ' )
124 tmpnewchar1 = tmpnewchar1 + " 伍 " ;
125 if (perchar == ' 6 ' )
126 tmpnewchar1 = tmpnewchar1 + " 陆 " ;
127 if (perchar == ' 7 ' )
128 tmpnewchar1 = tmpnewchar1 + " 柒 " ;
129 if (perchar == ' 8 ' )
130 tmpnewchar1 = tmpnewchar1 + " 捌 <span styl
2 * 大写金额转换Scriptlet类
3 *
4 * @author Spark (Email: spark.unt@gmail.com)
5 */
6 public class TransChineseMoneyScriptlet extends JRDefaultScriptlet {
7 /**/ /*
8 * 默认构造方法
9 */
10 public TransChineseMoneyScriptlet() {
11
12 }
13
14 /** */ /**
15 * 获得金额的汉字大写格式 <br>
16 * @param money 小写金额字符串
17 * @return 大写的汉字金额
18 */
19 public static String getChineseMoney(String money) {
20 String text = transChineseMoney1(money) + transChineseMoney2(money);
21 Pattern p = Pattern.compile( " 零分 " , Pattern.CASE_INSENSITIVE);
22 Matcher m = p.matcher(text);
23 text = m.replaceAll( "" );
24 return text;
25 }
26
27 /** */ /**
28 * 截得输入金额的整数部分,并将其转换成中文大写的格式 <br>
29 * <br>
30 * 其他描述:输入数字超过接受范围时拒绝转换并退出。<br>
31 * @param 传递参数字符串S 参数描述
32 * @return 返回转换后的字符串
33 */
34 public static String transChineseMoney1(String s) {
35 String ss = s;
36 String tmpnewchar = "" ;
37 String[] part = ss.split( " \\. " );
38
39 if (part[ 0 ].length() > 10 ) {
40 // 超出可转换位数
41 return "" ;
42 }
43 for ( int i = 0 ; i < part[ 0 ].length(); i ++ ) {
44 char perchar = part[ 0 ].charAt(i);
45 if (perchar == ' 0 ' )
46 tmpnewchar = tmpnewchar + " 零 " ;
47 if (perchar == ' 1 ' )
48 tmpnewchar = tmpnewchar + " 壹 " ;
49 if (perchar == ' 2 ' )
50 tmpnewchar = tmpnewchar + " 贰 " ;
51 if (perchar == ' 3 ' )
52 tmpnewchar = tmpnewchar + " 叁 " ;
53 if (perchar == ' 4 ' )
54 tmpnewchar = tmpnewchar + " 肆 " ;
55 if (perchar == ' 5 ' )
56 tmpnewchar = tmpnewchar + " 伍 " ;
57 if (perchar == ' 6 ' )
58 tmpnewchar = tmpnewchar + " 陆 " ;
59 if (perchar == ' 7 ' )
60 tmpnewchar = tmpnewchar + " 柒 " ;
61 if (perchar == ' 8 ' )
62 tmpnewchar = tmpnewchar + " 捌 " ;
63 if (perchar == ' 9 ' )
64 tmpnewchar = tmpnewchar + " 玖 " ;
65
66 int j = part[ 0 ].length() - i - 1 ;
67 if (j == 0 )
68 tmpnewchar = tmpnewchar + " 圆 " ;
69 if (j == 1 && perchar != 0 )
70 tmpnewchar = tmpnewchar + " 拾 " ;
71 if (j == 2 && perchar != 0 )
72 tmpnewchar = tmpnewchar + " 佰 " ;
73 if (j == 3 && perchar != 0 )
74 tmpnewchar = tmpnewchar + " 仟 " ;
75 if (j == 4 && perchar != 0 )
76 tmpnewchar = tmpnewchar + " 万 " ;
77 if (j == 5 && perchar != 0 )
78 tmpnewchar = tmpnewchar + " 拾 " ;
79 if (j == 6 && perchar != 0 )
80 tmpnewchar = tmpnewchar + " 佰 " ;
81 if (j == 7 && perchar != 0 )
82 tmpnewchar = tmpnewchar + " 仟 " ;
83 if (j == 8 && perchar != 0 )
84 tmpnewchar = tmpnewchar + " 亿 " ;
85 if (j == 9 && perchar != 0 )
86 tmpnewchar = tmpnewchar + " 拾 " ;
87 }
88 return tmpnewchar;
89 }
90
91 /** */ /**
92 * 截得输入金额的小数部分,并将其转换成中文大写的格式 <br>
93 * <br>
94 * 其他描述:小数部分超过两位时系统自动截断。<br>
95 *
96 * @param 传递参数字符串
97 *
98 * @return 返回转换后的字符串
99 */
100 public static String transChineseMoney2(String s) {
101 String ss = s;
102 String tmpnewchar1 = "" ;
103 String[] part = ss.split( " \\. " );
104
105 if (ss.indexOf( " . " ) != - 1 ) {
106 if (part[ 1 ].length() > 2 ) {
107 // MessageDialog.openInformation(null,"提示","小数点之后只能保留两位,系统将自动截段");
108 part[ 1 ] = part[ 1 ].substring( 0 , 2 );
109 }
110 for ( int i = 0 ; i < part[ 1 ].length(); i ++ ) {
111 char perchar = part[ 1 ].charAt(i);
112 // System.out.println(perchar);
113 if (perchar == ' 0 ' )
114 tmpnewchar1 = tmpnewchar1 + " 零 " ;
115 if (perchar == ' 1 ' )
116 tmpnewchar1 = tmpnewchar1 + " 壹 " ;
117 if (perchar == ' 2 ' )
118 tmpnewchar1 = tmpnewchar1 + " 贰 " ;
119 if (perchar == ' 3 ' )
120 tmpnewchar1 = tmpnewchar1 + " 叁 " ;
121 if (perchar == ' 4 ' )
122 tmpnewchar1 = tmpnewchar1 + " 肆 " ;
123 if (perchar == ' 5 ' )
124 tmpnewchar1 = tmpnewchar1 + " 伍 " ;
125 if (perchar == ' 6 ' )
126 tmpnewchar1 = tmpnewchar1 + " 陆 " ;
127 if (perchar == ' 7 ' )
128 tmpnewchar1 = tmpnewchar1 + " 柒 " ;
129 if (perchar == ' 8 ' )
130 tmpnewchar1 = tmpnewchar1 + " 捌 <span styl
发表评论
-
在ofbiz框架中实现https双向认证(笔记)
2016-04-08 10:16 409ofbiz默认的配置文件中没有提供服务端信任的证书配置项, ... -
hadoop2.4在windows7搭建单节点环境的简要介绍
2014-05-27 16:18 846本文参照 hadoop2.2在window7上搭建单节点 ... -
关于ofbiz 集成urlrewritefilter实现url 伪静态化
2013-03-19 12:52 1655关于ofbiz 集成urlrewritefilter实现ur ... -
hadoop学习笔记(动态删除节点)
2012-09-19 13:41 925在hadoop集群环境下需要将两台datanode删除,为了不 ... -
CentOS系统安装Tomcat切换JDK的方法
2011-10-14 09:38 1069CentOS系统安装Tomcat切换JDK的方法 ... -
一个从字符串中提取金额的正则表达式
2011-05-19 15:44 2037一个从字符串中提取金额的正则表达式,初 ... -
tomcat远程调试 方法1:适用于tomcat6 修改startup.bat 在尾部修改成以下列方式启动 set JPDA_ADDRESS=8000 se
2011-01-05 12:37 1427tomcat 6 远程调试 ... -
Hadoop学习笔记二 安装部署
2010-07-14 11:22 697原文 http://www.cnblogs.com ... -
Hadoop学习笔记一 简要介绍
2010-07-14 11:21 697这里先大致介绍一下Hadoop. 本文大部分内容都 ... -
Java获取客户端真实IP地址的两种方法(转)
2010-05-14 15:04 1171在JSP里,获取客户端的IP地址的方法是:request.ge ... -
20款开源搜索引擎系统
2010-04-16 19:32 1162一些开源搜索引擎系统介绍,包含开源Web搜索引擎和开源桌面搜索 ... -
jdk工具keytool和jarsigner帮助Part2(转)
2010-01-08 12:46 2086jdk工具keytool和jarsigner帮 ... -
jdk工具keytool和jarsigner帮助Part1
2010-01-08 12:41 1549jdk工具keytool和jarsigner帮 ... -
JPA 批注参考 (转载)
2009-03-30 13:27 951JPA批注参考 1 JPA 批 ... -
通过urlrewrite和filter实现动态网站生成静态页并缓存的方案
2008-10-06 14:37 3231关于改造动态网站为生成静态页的方案 url 重 ... -
jsp生成验证码
2008-01-15 15:27 837<%@ page contentType="i ... -
tomcat下配置使用awstats笔记
2008-01-10 11:43 4520tomcat下配置使用awstats笔记 1。环境 使用的 ... -
ip地址与Long型数据进行相互转换
2007-12-04 23:17 4413/** * 根据ip地址计算出long型的数据 * @ ... -
java对象初始化过程(转)
2007-04-22 22:57 1295java new 一个实例时候,对象初始化过程 1.父类 st ... -
java 中 Hashtable 排序 (转)
2007-04-10 22:41 4705import java.util.Arrays; import ...
相关推荐
在JasperReport报表中加入大写金额,在报表执行过程中使用scirptlet将存放着数字金额的变量读出转换成大写金额字符串后放入大写金额变量中。报表即可象显示普通字符变量一样显示大写金额。
JasperReport报表设计总结
Ireport实现金额大写 在irport里面写script脚本 完成转换
JasperReport 中交叉报表指南
ireport-5.6.0 Jasperreport 报表工具 jar包大全Two
iReport-JasperReport 报表开发指南,PDF格式,里面带有图文,入门性质的教程
使用Spring2.5+Struts2+ibatis+jasperreport3.1.4 实现Struts2与Jasperreport报表结合
JasperReport报表成型框架,可直接导入Myeclipse使用,附带文档有相关解释。
jasperreport报表开发小结,使用ireport设计报表模板,javabean作为数据源,整合springboot实现在线预览和导出各种格式的报表
springboot整合JasperReport实现报表功能文章所需的全部资源
ireport-5.6.0 Jasperreport 报表工具 jar包大全
JasperReport 水晶报表 , 支持子报表 多数据源。
iReport-5.6.0 Jasperreport
基于Web的报表在很多项目中都是需要的。而随着Struts2的流行,就应该研究一下在Struts2下如何利用JasperReports进行报表输出。本示例比较简单,采用的数据源即为JavaBean,而没有采用复杂的数据库,其实原理是一样的...
jasperreport 6.4.1报表动态列,以及生成导出html,可直接导入到eclipse中进行运行,包含一个完整的demo
软件说明: jasperreport 是一款报表打印组件,是开放源代码组织sf.net 中的一个java 报表打印工 程,在我写这篇文章时,jasperreport 的最新版本是0.5.2 版,jasperreport 的最新版本可以 从...
使用java语言,ORACLE数据库,JasperReport报表工具开发的一个完整项目代码示例.