@SuppressWarnings("deprecation") @GET @POST @Path("/importServicesCompSegMapping") @Produces(MediaType.APPLICATION_JSON) public void importPartKitCompSegMapping( @Context HttpServletRequest request, @Context HttpServletResponse response, @Context ServletContext servletContext) { DiskFileUpload uploadFile = new DiskFileUpload(); uploadFile.setHeaderEncoding("utf8"); List<ServicesSegMappingVo> servicesSegmMappingList = new ArrayList<ServicesSegMappingVo>(); InputStream fileInputSteam = null; try { List<?> items = uploadFile.parseRequest(request); ListIterator<?> listIterator = items.listIterator(); while (listIterator.hasNext()) { FileItem item = (FileItem) listIterator.next(); String name = item.getName(); if (RCHelper.isExcelFile(name)) { fileInputSteam = item.getInputStream(); Workbook workBook = Workbook.getWorkbook(fileInputSteam); Sheet sheet = workBook.getSheet(0); int rowCount = sheet.getRows(); // int colCount = sheet.getColumns(); Cell cell = null; ServicesSegMappingVo servicesSegMappingVo = null; for (int row = 1; row < rowCount; row++) { servicesSegMappingVo = new ServicesSegMappingVo(); cell = sheet.getCell(0, row); if (cell.getContents() != null) { servicesSegMappingVo.setWorkItemId(cell.getContents()); } cell = sheet.getCell(1, row); if (cell.getContents() != null) { servicesSegMappingVo.setWorkItemName(cell.getContents()); } cell = sheet.getCell(2, row); if (cell.getContents() != null) { servicesSegMappingVo.setSegmentLevel(cell.getContents()); } cell = sheet.getCell(3, row); if (cell.getContents() != null) { servicesSegMappingVo.setAllocationPeriod(cell.getContents()); } cell = sheet.getCell(4, row); if (cell.getContents() != null) { servicesSegMappingVo.setEquipmentTechnology(cell.getContents()); } cell = sheet.getCell(5, row); if (cell.getContents() != null) { if (!"".equals(StringUtils.nvl(cell.getContents()))) { String[] segm = cell.getContents().split("#"); servicesSegMappingVo.setCompSegmName(segm[0]); servicesSegMappingVo.setCompSegmId(segm[1]); } } servicesSegmMappingList.add(servicesSegMappingVo); } // partkitSegmMappingList.size(); } else { ObjectMapper mapper = new ObjectMapper(); mapper.configure( SerializationConfig.Feature.WRITE_NULL_PROPERTIES, false); mapper.getSerializationConfig().setSerializationInclusion( Inclusion.ALWAYS); String errmsg = "Please upload file with extention '.XLS' or '.XLX'"; String jsonData = "{total:0,success:false,errorMessage:\"" + errmsg + "\"}"; logger.debug(jsonData); PrintWriter pw = response.getWriter(); pw.write(jsonData); pw.flush(); pw.close(); } } ObjectMapper mapper = new ObjectMapper(); mapper.configure( SerializationConfig.Feature.WRITE_NULL_PROPERTIES, false); mapper.getSerializationConfig().setSerializationInclusion( Inclusion.ALWAYS); PrintWriter pw = response.getWriter(); String json = new Gson().toJson(servicesSegmMappingList); String str = "{success:true,servicesSegmMappingList : "+json+"}"; pw.write(str); pw.flush(); pw.close(); } catch (FileUploadException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (BiffException e) { e.printStackTrace(); }finally { logger.info("finally"); if (fileInputSteam != null) { try { fileInputSteam.close(); } catch (IOException ex) { ; } } } //return "partkitSegmMappingList"; } js var jsonData = Ext.JSON.decode(action.response.responseText); //alert(jsonData.partkitSegmMappingList); grid.store.removeAll(); grid.store.loadData(jsonData.servicesSegmMappingList);
downViewServices fileName = "ViewServices.xls"; templatePath = "/resources/template/ViewServices.xls";//要下载的模板,一般表格头在里边 try { InputStream is = this.getClass().getResourceAsStream( templatePath); ViewServicesList viewServicesList; viewServicesList = this.findServices(request, response); List<ViewServicesVo> records = viewServicesList.getViewServicesList(); wwb = XLSUtil.getRateXlsFile(records, outputStream, is, 11); } catch (Exception e) { e.printStackTrace(); } @SuppressWarnings({ "deprecation", "rawtypes", "unchecked" }) public static WritableWorkbook getRateXlsFile(List recordsList, OutputStream os, InputStream is, int reportType) throws BiffException, IOException, WriteException { Workbook template = Workbook.getWorkbook(is); WritableWorkbook wwb = Workbook.createWorkbook(os, template); WritableSheet sheet = wwb.getSheet(0); sheet.setProtected(true); WritableCellFormat lockCF = getLockCellFormat(); WritableCellFormat unlockCF = getUnlockCellFormat(); if (reportType == RCATConstants.REPORT_LOH_SHOP_RATE) { // LOH shop rate getRateRecord(recordsList, lockCF, unlockCF, sheet); } else if (reportType == RCATConstants.REPORT_LOH_COMP_RATE) { getCompRateRecord(recordsList, lockCF, unlockCF, sheet); } else if (reportType == 3) { // exportFinalCatalog(recordsList, lockCF, sheet); } else if (reportType == 4) { getViewTechnologiesRecord(recordsList, lockCF, sheet); } else if (reportType == 5) { getPartKitsRecord(recordsList, lockCF, sheet); } else if (reportType == 6) { getShopCClRecord(recordsList, lockCF, sheet); } else if (reportType == 8) { getRateRecord(recordsList, lockCF, unlockCF, sheet); }else if (reportType == 10) { getServiceCatalog(recordsList, lockCF, unlockCF, sheet); }else if (reportType == 11) { getServices(recordsList, lockCF, unlockCF, sheet); } return wwb; } private static void getServices(List recordsList, WritableCellFormat lockCF, WritableCellFormat unlockCF, WritableSheet sheet) throws BiffException, IOException, WriteException{ if (!recordsList.isEmpty()) { Iterator<ViewServicesVo> itr = recordsList.iterator(); ViewServicesVo viewServicesVo = null; int startRowNumber = 1; Label cell; while (itr.hasNext()) { viewServicesVo = (ViewServicesVo) itr.next(); cell = new Label(0, startRowNumber, viewServicesVo.getAtaNumber(), lockCF); sheet.addCell(cell); cell = new Label(1, startRowNumber, viewServicesVo.getEquipTech(), lockCF); sheet.addCell(cell); cell = new Label(2, startRowNumber, viewServicesVo.getWorkItemId(), lockCF); sheet.addCell(cell); cell =new Label(3, startRowNumber, viewServicesVo.getWorkItemName(), lockCF); sheet.addCell(cell); cell = new Label(4, startRowNumber, viewServicesVo.getSeglevel(), lockCF); sheet.addCell(cell); cell = new Label(5, startRowNumber, viewServicesVo.getAllocationPeriod(), lockCF); sheet.addCell(cell); cell = new Label(6, startRowNumber, viewServicesVo.getCompSegName(), lockCF); sheet.addCell(cell); startRowNumber++; } } }
相关推荐
Ext生成报表导出到Excel,用Eclipse直接导入进去,发布就可以用,经过测试IE8可以显示,也可以导出
Ext完整例子,含jar包,建好表可直接运行,含Ext导出excel
程序是jsp ,可以直接导入myeclipse,中文没有乱码问题,ie、firefox中正常导出。
SpringMVC+ExtJs4.2实例 导入项目链接数据库即可运行 数据库用的是MySql 完全遵循ExtJs4.2的MVC模式来分成
SpringMVC+ExtJs4.2实例 导入项目链接数据库即可运行 数据库用的是MySql 完全遵循ExtJs4.2的MVC模式来分成
先用ExportDB.java向表中导入数据,启动服务http://localhost:8080/export就能看到效果了
Spring+springMVC+hibernate做的一个导入Excel,前端简单就是用easyUI做一个文件选择,可以自己随便写一个页面。可以显示失败条数,失败是excel的那一条 方便改。
strut2+hibernate+spring+extjs3.0+excel 动态加载grid 数据导出excel,导入excel datasource自己修改你自己的数据源,数据库中的表可见实体类创建,或者自己修改实体类
搜索了蛮久,找到一些例子,因为我是初学者的缘故大多不知道怎么使用。。 研究了一下那个源码,搞到现在终于实现了基本的下载。...在你要用到的JS代码的Ext.onReady()的开始加上 代码如下: Ext.Loader
在UI中除了使用了fineui之外,还结合了ext,使得UI体验上比较丰富,包括了一个用ext封装了SWFUpload.js的组件(带进度条),另外UI提供一个可以通过xml文件配置通用的导入导出Excel,在户籍管理和业务往来中用到。...
户籍管理,基本是居民户口簿中的信息管理(户籍类型、与户主关系、政治面目、居民户口簿、常住人口报表(支持模板导出、导入导出Excel)) 信访登记(信访渠道、问题分类、信访登记、信访跟进) 业务往来(地区资料...
系统用户:对各个基本的组会员增删改查,单发、群发邮件短信,导入导出excel表格,批量删除 3. 会员管理:对前台用户管理,分配会员级别,到期时间,状态,联系信息等资料 4. 菜单管理:增删改查菜单 ztree(自定义...
系统用户:对各个基本的组会员增删改查,单发、群发邮件短信,导入导出excel表格,批量删除 3. 会员管理:对前台用户管理,分配会员级别,到期时间,状态,联系信息等资料 4. 菜单管理:增删改查菜单 ztree(自定义...
1、此程序为基于.NET3.5版本上1.0Bete版本(VS2008+MSSQL2005),接触...用户信息则可以导出XML、Excel等格式。 5、附带“Ext3.0中文文档.CHM”一本 将压缩包 “DLL备份” 中的文件,放到web/bin/ 目录中 替换以前的
用ssh+extjs做的一个小项目,麻雀虽小,五脏俱全,里面涉及到文件上传,数据导入导出excel,pdf,web打印(jasperreport)等等.由于jar包太大,分开上传,有需要的朋友可以看看,如有小错误,竞请谅解,相信对需要的人...
支持在Excel中导入导出的双向编辑操作。 B、数据模板定义、同步、比对更新等功能。 C、采用方案定义、支持多个工程模式。 D、不同数据库平台数据类型自动转换功能。您只需采用比较熟悉的数据库进行定义、 系统会...
5、导入导出Excel数据,支持xlsx和xls文件。 6、资源管理(菜单管理)。 7、用户管理和部门管理。 8、权限管理。不仅可管理各个功能模块的权限,也可以管理功能模块里的页面按钮权限。 9、报表统计。也可以嵌入其他...
常用的工具类、基于Ext.Net封装的控件库、Excel导入导出帮助类、基于Winform的控件库、权限框架(用户管理、角色管理、功能管理)、ORM框架 以及一个应用程序基础框架,实现了做一个后台管理系统所需要的最基本例如...