| | |
| | | //获取jar包所在目录 |
| | | ApplicationHome applicationHome = new ApplicationHome(getClass()); |
| | | //在jar包所在目录下生成一个upload文件夹用来存储上传的图片 |
| | | String path = applicationHome.getSource().getParentFile().toString() + "/static/img"; |
| | | String path = applicationHome.getSource().getParentFile().toString() + "\\static\\img"; |
| | | try { |
| | | //InputStream inputStream = WordUtil.class.getClassLoader().getResourceAsStream("word/尘负荷监测报告.docx"); |
| | | InputStream stream = WordUtil.class.getClassLoader().getResourceAsStream("word/盐城市走航监测报告.docx"); |
| | |
| | | // picMap.put("urlImg1", Pictures.ofUrl("G:\\home\\3d423e3cb05d7edc35c38e3173af2a0d.jpg", PictureType.JPEG).size(500, 500).create()); |
| | | int i =1; |
| | | for (DailyVo dailyVo : dailyVos) { |
| | | Map picMap = new HashMap(); |
| | | Map picMap1 = new HashMap(); |
| | | Map picMap2 = new HashMap(); |
| | | Map picMap3 = new HashMap(); |
| | | Map picMap4 = new HashMap(); |
| | | Map picMap5 = new HashMap(); |
| | | Map picMap6 = new HashMap(); |
| | | Map picMap7 = new HashMap(); |
| | | Map picMap8 = new HashMap(); |
| | | List<String> images = dailyVo.getImages(); |
| | | if (!ObjectUtils.isEmpty(images)){ |
| | | picMap.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(0))); |
| | | pic1.add(picMap); |
| | | picMap.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(1))); |
| | | pic2.add(picMap); |
| | | picMap.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(2))); |
| | | pic3.add(picMap); |
| | | picMap.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(3))); |
| | | pic4.add(picMap); |
| | | picMap.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(4))); |
| | | pic5.add(picMap); |
| | | picMap.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(5))); |
| | | pic6.add(picMap); |
| | | picMap.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(6))); |
| | | pic7.add(picMap); |
| | | picMap.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(7))); |
| | | pic8.add(picMap); |
| | | |
| | | picMap1.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(0))); |
| | | // picMap1.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\0a4ab467-304d-4871-948f-55aa7e820975.png")); |
| | | pic1.add(picMap1); |
| | | picMap2.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(1))); |
| | | // picMap2.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\0a4ab467-304d-4871-948f-55aa7e820975.png")); |
| | | pic2.add(picMap2); |
| | | picMap3.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(2))); |
| | | pic3.add(picMap3); |
| | | picMap4.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(3))); |
| | | pic4.add(picMap4); |
| | | picMap5.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(4))); |
| | | pic5.add(picMap5); |
| | | picMap6.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(5))); |
| | | pic6.add(picMap6); |
| | | picMap7.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(6))); |
| | | pic7.add(picMap7); |
| | | picMap8.put("urlImg"+i,new PictureRenderData(500, 500, path+"\\"+images.get(7))); |
| | | pic8.add(picMap8); |
| | | i++; |
| | | } |
| | | detailList1.add(dailyVo.getCode()); |
| | | detailList2.add(dailyVo.getCode()); |
| | |
| | | map.put("code",builder); |
| | | map.put("time1",DateUtils.getCurCNDate()); |
| | | // map.put("pho",new PictureRenderData(100, 100, "G:\\home\\3d423e3cb05d7edc35c38e3173af2a0d.jpg")); |
| | | // Pictures.ofLocal(null); |
| | | // map.put("pho1",new PictureRenderData(100, 100, path+"\\0a4ab467-304d-4871-948f-55aa7e820975.png")); |
| | | // map.put("pho1",new PictureRenderData(500, 500, path+"\\0a4ab467-304d-4871-948f-55aa7e820975.png")); |
| | | |
| | | HackLoopTableRenderPolicy policy = new HackLoopTableRenderPolicy(); |
| | | Configure config = Configure.newBuilder().bind("detailList1", policy).bind("detailList2", policy).bind("detailList3", policy).bind("detailList4", policy) |
| | |
| | | response.addHeader("Content-Disposition", "attachment;fileName=ce.docx" ); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | //保存到本地 |
| | | // File file1 = new File("G:\\test\\test2.docx"); |
| | | // FileOutputStream out = new FileOutputStream(file1); |
| | | // compile.write(out); |
| | | /* File file1 = new File("G:\\test\\test2.docx"); |
| | | FileOutputStream out = new FileOutputStream(file1); |
| | | compile.write(out);*/ |
| | | //下载到线上 |
| | | OutputStream out = response.getOutputStream(); |
| | | compile.write(out); |