org.jxls.util.JxlsHelper Java Examples
The following examples show how to use
org.jxls.util.JxlsHelper.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReportGenerator.java From rebuild with GNU General Public License v3.0 | 6 votes |
/** * @return file in temp */ public File generate() { String excelSuffix = this.template.getName().endsWith(".xlsx") ? ".xlsx" : ".xls"; File dest = SysConfiguration.getFileOfTemp("REPORT-" + System.currentTimeMillis() + excelSuffix); try(InputStream is = new FileInputStream(template)) { try (OutputStream os = new FileOutputStream(dest)) { Map<String, Object> data = getDataContext(); Context context = new Context(data); JxlsHelper.getInstance().processTemplate(is, os, context); } } catch (IOException ex) { throw new RebuildException(ex); } return dest; }
Example #2
Source File: DictConsoleController.java From springboot-plus with BSD 3-Clause "New" or "Revised" License | 5 votes |
@PostMapping(MODEL + "/excel/export.json") @Function("dict.export") @ResponseBody public JsonResult<String> export(HttpServletResponse response,UserQuery condtion) { String excelTemplate ="excelTemplates/admin/dict/dict_collection_template.xls"; PageQuery<CoreUser> page = condtion.getPageQuery(); //取出全部符合条件的 page.setPageSize(Integer.MAX_VALUE); page.setPageNumber(1); page.setTotalRow(Integer.MAX_VALUE); List<CoreDict> dicts =dictService.queryExcel(page); try(InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(excelTemplate)) { if(is==null) { throw new PlatformException("模板资源不存在:"+excelTemplate); } FileItem item = fileService.createFileTemp("dict_collection.xls"); OutputStream os = item.openOutpuStream(); Context context = new Context(); context.putVar("dicts", dicts); JxlsHelper.getInstance().processTemplate(is, os, context); os.close(); //下载参考FileSystemContorller return JsonResult.success(item.getPath()); } catch (IOException e) { throw new PlatformException(e.getMessage()); } }
Example #3
Source File: UserConsoleController.java From springboot-plus with BSD 3-Clause "New" or "Revised" License | 5 votes |
@PostMapping(MODEL + "/excel/export.json") @Function("user.export") @ResponseBody public JsonResult<String> export(HttpServletResponse response,UserQuery condtion) { String excelTemplate ="excelTemplates/admin/user/user_collection_template.xls"; PageQuery<CoreUser> page = condtion.getPageQuery(); //取出全部符合条件的 page.setPageSize(Integer.MAX_VALUE); page.setPageNumber(1); page.setTotalRow(Integer.MAX_VALUE); List<UserExcelExportData> users =userConsoleService.queryExcel(page); try(InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(excelTemplate)) { if(is==null) { throw new PlatformException("模板资源不存在:"+excelTemplate); } FileItem item = fileService.createFileTemp("user_collection.xls"); OutputStream os = item.openOutpuStream(); Context context = new Context(); context.putVar("users", users); JxlsHelper.getInstance().processTemplate(is, os, context); //下载参考FileSystemContorller return JsonResult.success(item.getPath()); } catch (IOException e) { throw new PlatformException(e.getMessage()); } }