- 浏览: 228413 次
- 性别:
- 来自: 沈阳
-
文章分类
- 全部博客 (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

3

4

5

6



7


8

9

10



11

12

13

14


15

16

17

18

19



20

21

22

23

24

25

26

27


28

29

30

31

32

33

34



35

36

37

38

39



40

41

42

43



44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91


92

93

94

95

96

97

98

99

100



101

102

103

104

105



106



107

108

109

110



111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

发表评论
-
在ofbiz框架中实现https双向认证(笔记)
2016-04-08 10:16 486ofbiz默认的配置文件中没有提供服务端信任的证书配置项, ... -
hadoop2.4在windows7搭建单节点环境的简要介绍
2014-05-27 16:18 914本文参照 hadoop2.2在window7上搭建单节点 ... -
关于ofbiz 集成urlrewritefilter实现url 伪静态化
2013-03-19 12:52 1771关于ofbiz 集成urlrewritefilter实现ur ... -
hadoop学习笔记(动态删除节点)
2012-09-19 13:41 1051在hadoop集群环境下需要将两台datanode删除,为了不 ... -
CentOS系统安装Tomcat切换JDK的方法
2011-10-14 09:38 1130CentOS系统安装Tomcat切换JDK的方法 ... -
一个从字符串中提取金额的正则表达式
2011-05-19 15:44 2161一个从字符串中提取金额的正则表达式,初 ... -
tomcat远程调试 方法1:适用于tomcat6 修改startup.bat 在尾部修改成以下列方式启动 set JPDA_ADDRESS=8000 se
2011-01-05 12:37 1500tomcat 6 远程调试 ... -
Hadoop学习笔记二 安装部署
2010-07-14 11:22 745原文 http://www.cnblogs.com ... -
Hadoop学习笔记一 简要介绍
2010-07-14 11:21 775这里先大致介绍一下Hadoop. 本文大部分内容都 ... -
Java获取客户端真实IP地址的两种方法(转)
2010-05-14 15:04 1223在JSP里,获取客户端的IP地址的方法是:request.ge ... -
20款开源搜索引擎系统
2010-04-16 19:32 1237一些开源搜索引擎系统介绍,包含开源Web搜索引擎和开源桌面搜索 ... -
jdk工具keytool和jarsigner帮助Part2(转)
2010-01-08 12:46 2162jdk工具keytool和jarsigner帮 ... -
jdk工具keytool和jarsigner帮助Part1
2010-01-08 12:41 1611jdk工具keytool和jarsigner帮 ... -
JPA 批注参考 (转载)
2009-03-30 13:27 1021JPA批注参考 1 JPA 批 ... -
通过urlrewrite和filter实现动态网站生成静态页并缓存的方案
2008-10-06 14:37 3307关于改造动态网站为生成静态页的方案 url 重 ... -
jsp生成验证码
2008-01-15 15:27 899<%@ page contentType="i ... -
tomcat下配置使用awstats笔记
2008-01-10 11:43 4568tomcat下配置使用awstats笔记 1。环境 使用的 ... -
ip地址与Long型数据进行相互转换
2007-12-04 23:17 4518/** * 根据ip地址计算出long型的数据 * @ ... -
java对象初始化过程(转)
2007-04-22 22:57 1362java new 一个实例时候,对象初始化过程 1.父类 st ... -
java 中 Hashtable 排序 (转)
2007-04-10 22:41 4752import java.util.Arrays; import ...
相关推荐
Ireport实现金额大写 在irport里面写script脚本 完成转换
在JasperReport报表中加入大写金额,在报表执行过程中使用scirptlet将存放着数字金额的变量读出转换成大写金额字符串后放入大写金额变量中。报表即可象显示普通字符变量一样显示大写金额。
在 JasperReport 中,交叉报表需要设置 subDataSets 数据源。subDataSets 是一种特殊的数据源,它可以从外部数据源中获取数据,并将其存储在内存中,以便于报表生成。要设置 subDataSets 数据源,需要在报表设计中...
在JasperReport中,子报表是用于在主报表内部嵌套其他报表的一个功能,可以用来组织和展示更复杂的结构化数据。标题、描述和标签提示我们,这个例子将围绕如何使用JasperReport创建并集成子报表展开。 首先,我们要...
4. **调用转换函数**:在报表中,你可以将这个转换函数绑定到一个字段或者表达式上,以便在生成报表时自动将金额字段转换为大写。例如,可以创建一个Java表达式`PositiveIntegerToHanStr($F{amount}.toString())`,...
《iReport-JasperReport 报表开发指南》是一本针对初学者的专业教程,旨在帮助读者...在实际工作中,报表系统对于决策支持和业务分析至关重要,因此,掌握iReport和JasperReport的使用技巧将对你的IT职业生涯大有裨益。
在“JasperReport动态报表归并行数据”这个主题中,我们主要讨论如何利用JasperReport来处理和展示动态变化的数据,并实现数据的合并。 1. **动态报表设计**: JasperReport支持XML或Java代码定义报表模板(jrxml...
"ireport-5.6.0 Jasperreport 报表工具 jar包大全" 这个标题提到了两个关键组件:iReport和JasperReport,它们都是用于创建和设计报表的重要工具,尤其在Java开发环境中广泛使用。标题中的“5.6.0”是这两个工具的...
这些库包括JasperReport的核心库jasperreports.jar,以及可能需要的额外库如iTextAsian.jar,以支持中文字符在PDF报表中的正确显示。此外,可能还需要Struts2的特定插件或配置,以确保框架能够与JasperReport顺利...
总结,JasperReport作为一个灵活的报表工具,为开发者提供了丰富的报表设计和数据呈现方式,使其能够在各种Java应用中生成高质量的报表。配合详细的文档和开发注意事项,可以有效地提高开发效率和报表质量。对于那些...
在JasperReport中,iBatis可以用于从数据库中检索报表所需的数据。通过XML映射文件,iBatis可以动态地执行SQL,将查询结果转换为Java对象,供JasperReport使用。 JasperReport3.1.4是报表设计和生成的核心组件。它...
首先在 ireport 中设计报表模板,生成 XML 格式的文件,编译后生成 jasper 后缀的二进制文件。将编译好的.jasper 文件拷贝到 WEB 工程下,通过代码填充数据源生成最终的报表。 五、ireport 使用说明 Jaspersoft ...
标题中的“jasperreport报表模板预览 applet与servlet通信”揭示了本文将要讨论的重点,即如何在Java环境中使用JasperReport库创建报表模板,并通过Applet和Servlet进行数据交互来实现预览功能。JasperReport是一个...
JasperReport是一个开源的报表引擎,它允许开发者在Java应用程序中生成静态和动态报表。它的强大之处在于可以处理多种数据源,如数据库查询结果、XML文件、Java对象等,并能将这些数据转化为用户友好的格式,如PDF、...
在SpringBoot中整合JasperReport,首先你需要在项目中添加相应的依赖。在`pom.xml`文件中,引入JasperReport和SpringBoot对PDF处理的支持,例如: ```xml <!-- JasperReport --> <groupId>...
7. **子报表和分组**:通过子报表功能,可以在一个主报表中嵌套其他报表,以呈现更复杂的结构。分组功能则可以根据特定字段对数据进行分类。 8. **变量和计算**:iReport支持定义变量,用于计算和存储报表中的值,...
- **集成:** 水晶报表在.NET环境中的集成更加紧密,而JasperReport更适应Java生态系统。 **4. 使用JasperReport的步骤:** - 设计报表模板:使用iReport或Jaspersoft Studio创建报表布局。 - 连接数据源:配置报表...
在本项目中,“jasperReport测试项目(含报表设计文件).rar”是一个压缩包,包含了一系列用于JasperReport报表设计的文件,帮助我们理解和实践报表开发。 报表设计是JasperReport的核心功能,通过使用JRXML文件,...