欢迎来到天天文库
浏览记录
ID:35515464
大小:215.13 KB
页数:14页
时间:2019-03-25
《ssm框架使用poi技术导出excel》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、POI框架是Apache开源的可以导出导入Excel表的,本博客介绍在SSM(Spring+SpringMVC+Mybatis)项目里,如何使用POI框架,导出Excel表这里我们先要去Apache官网下载jar然后,就可以先编程了先提供一个封装的httpservlet请求和添加数据的类[java] viewplain copy 1.public class PageData extends HashMap implements Map{ 2. 3. private static final long serialVersionUID = 1L; 4.
2、 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 =
3、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. O
4、bject 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;i5、 value = values[i] + ","; 26. } 27. value = value.substring(0, value.length()-1); 28. }else{ 1. value = valueObj.toString(); 2. } 3. returnMap.put(name, value); 4. } 5. map 6、= returnMap; 6. } 7. 8. public PageData() { 9. map = new HashMap(); 10. } 11. 12. @Override 13. public Object get(Object key) { 14. Object obj = null; 15. if(map.get(key) instanceof Object[]) { 16. Object[] arr = (Object[])7、map.get(key); 17. obj = request == null ? arr:(request.getParameter((String)key) == null ? arr:arr[0]); 18. } else { 19. obj = map.get(key); 20. } 21. return obj; 22. } 23. 24. public String getString(Obje
5、 value = values[i] + ","; 26. } 27. value = value.substring(0, value.length()-1); 28. }else{ 1. value = valueObj.toString(); 2. } 3. returnMap.put(name, value); 4. } 5. map
6、= returnMap; 6. } 7. 8. public PageData() { 9. map = new HashMap(); 10. } 11. 12. @Override 13. public Object get(Object key) { 14. Object obj = null; 15. if(map.get(key) instanceof Object[]) { 16. Object[] arr = (Object[])
7、map.get(key); 17. obj = request == null ? arr:(request.getParameter((String)key) == null ? arr:arr[0]); 18. } else { 19. obj = map.get(key); 20. } 21. return obj; 22. } 23. 24. public String getString(Obje
此文档下载收益归作者所有