使用vo注释做一个poi导出功能
来源:互联网 发布:下载塞班软件 编辑:程序博客网 时间:2024/05/22 17:10
1 jsp中:
<a href="${basePath}/manage/bulletinAction.do?method=exportMainProduct&is18th=1">导出公司主营产品</a>
2 action中:
/** * 导出主营产品 */ public void exportMainProduct(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { BulletinForm bulletinForm = (BulletinForm) form; bulletinForm.setRows(5000); List<Bulletin> list = bulletinService.find(bulletinForm); List<MainproductcnVo> mainproductcnVos = new ArrayList<MainproductcnVo>(); Iterator<Bulletin> it = list.iterator(); while (it.hasNext()) { Bulletin bulletin = (Bulletin) it.next(); MainproductcnVo mainproductcnVo = new MainproductcnVo(); BeanUtils.copyProperties(bulletin, mainproductcnVo); mainproductcnVos.add(mainproductcnVo); } SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:SS"); Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams( "CIOE2017主营产品", "导出时间:" + format.format(new Date()), "CIOE2017主营产品"), MainproductcnVo.class, mainproductcnVos);//主要!!用这一句话确定导出内容 OutputStream ops = null; try { ops = response.getOutputStream(); response.reset(); response.setContentType("application/octet-stream"); response.setHeader("Content-Disposition", "attachment; filename=mainproduct.xls"); // ops=new FileOutputStream("D:/AudienceRecord.xls"); workbook.write(ops); ops.flush(); System.out.println("ok"); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO: handle exception e.printStackTrace(); } finally { if (ops != null) { try { ops.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }
3 vo中,注释:
public class MainproductcnVo { @Excel(name = "公司中文名称", orderNum = "1") private String companynameCn; @Excel(name = "公司英文名称", orderNum = "2") private String companynameEn; @Excel(name="主营产品",orderNum = "3") private String mainproductcn; @Excel(name="电话",orderNum = "4") private String tel; @Excel(name="邮箱",orderNum = "5") private String email; //省略set/get方法}
阅读全文
0 0
- 使用vo注释做一个poi导出功能
- apache poi做的一个到出到导出Excel功能
- poi 导出功能。
- poi导出功能
- 使用POI操作EXECL做数据的导入与导出
- 使用Apache POI,实现导出Excel的功能
- java中如何使用POI来实现导出excel功能
- 利用POI做导出EXCEL
- POI导出excel,对于所有的VO实体都通用.
- POI(JAVA Excel导出功能)
- POI实现动态导出功能
- 使用poi导出excel
- 使用POI导出Excel
- 使用POI导出excel
- 使用POI导出Excel
- 使用POI导出excel
- 使用POI导出Excel
- 使用poi导出xls
- Windows消息类型及说明
- iOS开发-CocoaPods安装教程
- 下载并破解IntelliJ IDEA(2017)
- tensorflow实现卷积神经网(CNN),还加了个dropout
- Java项目和maven项目中如何获取&设置配置文件中的属性
- 使用vo注释做一个poi导出功能
- 什么样的_BUG_会让你目瞪口呆?
- Android 自定义View基本用法
- Eclipse曾经的行业之王_为何堕落了?
- 如何解决iframe框架在ios系统中的兼容性问题
- Java线程创建——继承Thread类
- 文章标题:Android常见组件Gallery的用法
- C 线程的创建
- 计算机视觉牛人博客和代码汇总(全)