没有合适的资源?快使用搜索试试~ 我知道了~
SSM框架使用POI技术导出Excel.pdf
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 128 浏览量
2021-10-02
12:22:11
上传
评论
收藏 714KB PDF 举报
温馨提示
试读
14页
SSM框架使用POI技术导出Excel.pdf
资源推荐
资源详情
资源评论
POI 框架是 Apache 开源的可以导出导入 Excel 表的,本博客介绍在
SSM(Spring+SpringMVC+Mybatis) 项目里,如何使用 POI 框架,导出
Excel 表
这里我们先要去 Apache 官网下载 jar
然后,就可以先编程了
先提供一个封装的 httpservlet 请求和添加数据的类
[java] view plain copy
1. public class PageData extends HashMap implements Map{
2.
3. private static final long serialVersionUID = 1L;
4.
5. Map map = null ;
6. HttpServletRequest request;
7.
8. public PageData(HttpServletRequest request){
9. this .request = request;
10. Map properties = request.getParameterMap();
11. Map returnMap = new HashMap();
12. Iterator entries = properties.entrySet().iterator();
13. Map.Entry entry;
14. String name = "" ;
15. String value = "" ;
16. while (entries.hasNext()) {
17. entry = (Map.Entry) entries.next();
18. name = (String) entry.getKey();
19. Object valueObj = entry.getValue();
20. if ( null == valueObj){
21. value = "" ;
22. } else if (valueObj instanceof String[]){
23. String[] values = (String[])valueObj;
24. for ( int i= 0;i<values.length;i++){
25. value = values[i] + "," ;
26. }
27. value = value.substring( 0, value.length()- 1);
28. } else {
29. value = valueObj.toString();
30. }
31. returnMap.put(name, value);
32. }
33. map = returnMap;
34. }
35.
36. public PageData() {
37. map = new HashMap();
38. }
39.
40. @Override
41. public Object get(Object key) {
42. Object obj = null ;
43. if (map.get(key) instanceof Object[]) {
44. Object[] arr = (Object[])map.get(key);
45. obj = request == null ? arr:(request.getParameter((String)key) =
= null ? arr:arr[ 0]);
46. } else {
47. obj = map.get(key);
48. }
49. return obj;
50. }
51.
52. public String getString(Object key) {
53. return (String)get(key);
54. }
55.
56. @SuppressWarnings ( "unchecked" )
57. @Override
58. public Object put(Object key, Object value) {
59. return map.put(key, value);
60. }
61.
62. @Override
63. public Object remove(Object key) {
64. return map.remove(key);
65. }
66.
67. public void clear() {
68. map.clear();
69. }
70.
71. public boolean containsKey(Object key) {
72. // TODO Auto-generated method stub
73. return map.containsKey(key);
74. }
75.
76. public boolean containsValue(Object value) {
77. // TODO Auto-generated method stub
78. return map.containsValue(value);
79. }
80.
81. public Set entrySet() {
82. // TODO Auto-generated method stub
83. return map.entrySet();
84. }
85.
86. public boolean isEmpty() {
87. // TODO Auto-generated method stub
88. return map.isEmpty();
89. }
90.
91. public Set keySet() {
92. // TODO Auto-generated method stub
93. return map.keySet();
94. }
95.
96. @SuppressWarnings ( "unchecked" )
97. public void putAll(Map t) {
98. // TODO Auto-generated method stub
99. map.putAll(t);
100. }
101.
102. public int size() {
103. // TODO Auto-generated method stub
104. return map.size();
105. }
106.
107. public Collection values() {
108. // TODO Auto-generated method stub
109. return map.values();
110. }
111.
112. }
写个实体类:
会员类
[java] view plain copy
1. public class Member {
2.
3. /**
4. * 会员账号
5. */
6. private String memberID;
7.
剩余13页未读,继续阅读
资源评论
资料大全
- 粉丝: 14
- 资源: 26万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功