java 添加图片到word中,并导出word到前端

遇到一个需求,需要发布统计图,导出统计图以word形式,这里介绍Java后台的方式;
1、前端传入图片的base64;传入统计图名,介绍等等,把导出接口做成通用的,这样可以导出任意统计图

  • 添加依赖(用的POI来实现)
          <dependency>
              <groupId>org.apache.poigroupId>
              <artifactId>poiartifactId>
              <version>3.9version>
          dependency>
          <dependency>
              <groupId>org.apache.poigroupId>
              <artifactId>poi-ooxmlartifactId>
              <version>3.9version>
          dependency>
          <dependency>
              <groupId>org.apache.xmlbeansgroupId>
              <artifactId>xmlbeansartifactId>
              <version>3.0.2version>
          dependency>
    
  • 代码(这里把参数自己写在这里,不演示前端传值部分):
    @Api(tags = "导出word相关接口")
      @RequestMapping("/evt/word")
      @RestController
      public class WordController {
      
      
      //    @GetMapping("/exportWord")
      //    public void exportWord( HttpServletResponse response)throws Exception{
      ////        @RequestBody ExportWordParam param,
      //        ExportWordParam param = new ExportWordParam();
      //        param.setTitle("11111111");
      //        param.setWordName("222222222222222");
      //        param.setImgBase64("iVBORw0KGgoAAAANSUhEUgAAAhwAAAECCAMAAACCFP44AAAACXBIWXMAAAsTAAALEwEAmpwYAAAKTWlDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVN3WJP3Fj7f92UPVkLY8LGXbIEAIiOsCMgQWaIQkgBhhBASQMWFiApWFBURnEhVxILVCkidiOKgKLhnQYqIWotVXDjuH9yntX167+3t+9f7vOec5/zOec8PgBESJpHmomoAOVKFPDrYH49PSMTJvYACFUjgBCAQ5svCZwXFAADwA3l4fnSwP/wBr28AAgBw1S4kEsfh/4O6UCZXACCRAOAiEucLAZBSAMguVMgUAMgYALBTs2QKAJQAAGx5fEIiAKoNAOz0ST4FANipk9wXANiiHKkIAI0BAJkoRyQCQLsAYFWBUiwCwMIAoKxAIi4EwK4BgFm2MkcCgL0FAHaOWJAPQGAAgJlCLMwAIDgCAEMeE80DIEwDoDDSv+CpX3CFuEgBAMDLlc2XS9IzFLiV0Bp38vDg4iHiwmy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G9s/M99DN99bU+NjW+drY+dza+eLg+uvq/Ozr/O3s/O7t/O/u/CQa3CYc3Cce3Sge3Ssh3Swi3Swj3i0k3i4l3i8m3jAn3jMq3zQr3zUs3zYt3zcu3zgv3zkw4Dkw3zox4Dsy4Dwz4D004D414D834UA44UI54UM64UQ74UU84UY+4khA4kpC4k1F409H41JK41JL5FNM5FZO5FlR5VtU5VxV5V9Y5mFa5mNc5mRd5mVe52Zf52dg52hh52li52pj52tl6G5n6G9o6HNt6XRu6Xlz6nt16n136n546n9664F764J864R/7IaB7IiD7IuG7Y2I7Y+K7ZGM7pCL7ZKN7pGM7ZOO7pSP7paR7piU75+b8KCc8KSg8aej8aik8auo8rKv87Sx87e09Lm29Lu49Ly59L+89cG+9cPB9sXD9svJ983L99DO+NPR+NTS+N7d+uDf+uPi++Tj++Xk++bl++fm++no/Ojn++rp/Ono+/Dw/fb2/vn5/vr6/vz8//7+//zo5/3r6uMTDuMUD+MVEOMWEeMXEuMYE+MaFfCFgvGHhPGJhvGOi/KRjvKUkfKWk/Shn/SmpPWpp/WsqvWurPa0sve5t/e6uPe9u/e/vffBv/rT0vrU0/rW1frY1/va2fvc2/vd3Pvg3/zj4vvi4fzl5Pzn5uEHAuEIA+EJBOEKBeILBuIMB+INCOIPCuIQC+QbF+QdGeQfG+QgHOUjH+UlIeUpJeUqJuYtKeYvK+YzL+c2Muc5Nec8OOg+OuhAPOlEQelGQ+lIRelKR+lMSepPTOtWU+tZVuteW+xiX+1mY+1qZ+1tau5wbu92dO99e/B/ffCAfvCCgPOZl/OenPjBwPjEw/jGxfnJyPnMy/nPzv3u7v3w8P719f729v75+f/7+//9/f///4DJalUAAAEAdFJOU////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wBT9wclAAAP2klEQVR42uzdaXwURRoGcKsrJEAIi0G5A4RATEICaBQWMYiEXcGA4Y6yHIICcikKAlkuJYR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);
      //    }
      
          @PostMapping("/exportWord")
          public void exportWord( HttpServletResponse response)throws Exception{
              ExportWordParam param = new ExportWordParam();
              param.setTitle("数字化城市管理系统区域评价统计表");
              param.setWordName("评价统计表");
              param.setImgBase64("iVBORw0KGgoAAAANSUhEUgAAAhwAAAECCAMAAACCFP44AAAACXBIWXMAAAsTAAALEwEAmpwYAAAKTWlDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVN3WJP3Fj7f92UPVkLY8LGXbIEAIiOsCMgQWaIQkgBhhBASQMWFiApWFBURnEhVxILVCkidiOKgKLhnQYqIWotVXDjuH9yntX167+3t+9f7vOec5/zOec8PgBESJpHmomoAOVKFPDrYH49PSMTJvYACFUjgBCAQ5svCZwXFAADwA3l4fnSwP/wBr28AAgBw1S4kEsfh/4O6UCZXACCRAOAiEucLAZBSAMguVMgUAMgYALBTs2QKAJQAAGx5fEIiAKoNAOz0ST4FANipk9wXANiiHKkIAI0BAJkoRyQCQLsAYFWBUiwCwMIAoKxAIi4EwK4BgFm2MkcCgL0FAHaOWJAPQGAAgJlCLMwAIDgCAEMeE80DIEwDoDDSv+CpX3CFuEgBAMDLlc2XS9IzFLiV0Bp38vDg4iHiwmyxQmEXKRBmCeQinJebIxNI5wNMzgwAABr50cH+OD+Q5+bk4eZm52zv9MWi/mvwbyI+IfHf/ryMAgQAEE7P79pf5eXWA3DHAbB1v2upWwDaVgBo3/ldM9sJoFoK0Hr5i3k4/EAenqFQyDwdHAoLC+0lYqG9MOOLPv8z4W/gi372/EAe/tt68ABxmkCZrcCjg/1xYW52rlKO58sEQjFu9+cj/seFf/2OKdHiNLFcLBWK8ViJuFAiTcd5uVKRRCHJleIS6X8y8R+W/QmTdw0ArIZPwE62B7XLbMB+7gECiw5Y0nYAQH7zLYwaC5EAEGc0Mnn3AACTv/mPQCsBAM2XpOMAALzoGFyolBdMxggAAESggSqwQQcMwRSswA6cwR28wBcCYQZEQAwkwDwQQgbkgBwKoRiWQRlUwDrYBLWwAx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PR+NTS+N7d+uDf+uPi++Tj++Xk++bl++fm++no/Ojn++rp/Ono+/Dw/fb2/vn5/vr6/vz8//7+//zo5/3r6uMTDuMUD+MVEOMWEeMXEuMYE+MaFfCFgvGHhPGJhvGOi/KRjvKUkfKWk/Shn/SmpPWpp/WsqvWurPa0sve5t/e6uPe9u/e/vffBv/rT0vrU0/rW1frY1/va2fvc2/vd3Pvg3/zj4vvi4fzl5Pzn5uEHAuEIA+EJBOEKBeILBuIMB+INCOIPCuIQC+QbF+QdGeQfG+QgHOUjH+UlIeUpJeUqJuYtKeYvK+YzL+c2Muc5Nec8OOg+OuhAPOlEQelGQ+lIRelKR+lMSepPTOtWU+tZVuteW+xiX+1mY+1qZ+1tau5wbu92dO99e/B/ffCAfvCCgPOZl/OenPjBwPjEw/jGxfnJyPnMy/nPzv3u7v3w8P719f729v75+f/7+//9/f///4DJalUAAAEAdFJOU////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wBT9wclAAAP2klEQVR42uzdaXwURRoGcKsrJEAIi0G5A4RATEICaBQWMYiEXcGA4Y6yHIICcikKAlkuJYRICCLHLklmhMUgghwiiAguiC6IcsgRORRRdzlFFLwRE377wWRm+qjq7pnumeme5/mYeaeH6frT3dNVXXUTQRBGbsIuQIADAQ4EOBDgQIADAQ4EOBDgQIADAQ4EAQ4EOBDgQIADAQ4EOBDgQIADAQ4EOBAEOBDgQIADAQ4EOBDgQIADAQ4EOBDgQBDgQIADAQ4EOBDgQIADAQ4EOBDgQIADAQ4EAQ4EOBDgQIADAQ4EOBDgQIADAQ4EOBAEOBDgQIADAQ4EOBDgQIADAQ4EOBDgQBDgQIADAQ4EOBDgQIADAQ4EOBDgQIADAQ4EAQ4EOBDgQIADAQ4EOBDgQIADAQ4EOBAEOBDgQIADAQ4EOBDgQIADAQ4EOBDgQBDgQIADAQ4EOHzP0uyH7klO6TSofiEIAIcohU+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mYzv3HSLBxFkabbSF7oPxw+b806OA64nrT/5SOTcJC8JLNxPEqAw3gcyz16X6+ahUPX8rHe5M4EM3Ac0I3j9Gk74TghGonwjVk4nIPNxTGDmIHjM504Tv9Ayq/stwuOvd9Ixiet3mMODlKcZaaNm4kpONbownH6jxtDO87ttQOOfRfk83NsOWoODlI81DwbtRym4Dh6XTuOD866J0l69/Ihi+P46It1ijfxrq8+aAoOQrJbm0MjcYzTlNvGh98mWnEcurxLfM/058uffmBFHAcOHvviwmtb2dPNlG26VGoGDhL3cKLauqBRw2tPz80viIubn5/3bN1RWX9tqWqj3bO6d8r+EtUc+XzNb0QbjqNfbzFiqJeZOCyR/EdSmCvQ9x8/S2EUUHHjyQPa8O5vjEwgIZGbQuA7hs98vPe9d3j0pXbOyBp5a4O5vDU/i3KjeyjfKEkbu4QQ4LBXwpYujYuLi0tY6tT6jmpzag+uITrspPZ7JsYRMnsshHB4GefiJjnT/l5nUt2pz86ND7HvDhwIcCDAgQAHAhwIcCDAgQAHAhwIcCDAgSDAgQAHAhwIcCDAgQAHAhwIcCDAgQAHggAHAhwIcCDAgfg1/x8Ate1CIJg9Qs4AAAAASUVORK5CYII=");
              exportSimpleWord(response,param);
          }
      
      
          public static void exportSimpleWord(HttpServletResponse response,ExportWordParam param) throws Exception {
              CustomXWPFDocument document = new CustomXWPFDocument();
              //String savePath = "D:/评价文件夹";
              String sourcePath = System.getProperty("user.dir");
              String savePath = sourcePath + "/" + TimeUtil.formatDateyyyyMMdd(TimeUtil.now());
              File path=new File(savePath);
              if(!path.exists()){//如果文件夹不存在
                  path.mkdir();//创建文件夹
              }
      //        String filePath = "D:/评价文件夹/"+param.getWordName()+ TimeUtil.formatDateyyyyMMdd(TimeUtil.now())+".doc";
      //        String filePath = "checkrepositorytemplate.doc";
              String fileName = String.valueOf(new Date().getTime()) + ".png";
      //        File fis=new File(filePath);
      //        FileOutputStream out = new FileOutputStream(new File(filePath ));
      //        InputStream in = new FileInputStream(fis);
      
              // 添加标题
              XWPFParagraph titleParagraph = document.createParagraph();
              // 设置段落居中
              titleParagraph.setAlignment(ParagraphAlignment.CENTER);
              XWPFRun titleRun = titleParagraph.createRun();
              titleRun.setText(param.getTitle());
              titleRun.setFontSize(20);
              titleRun.setFontFamily("宋体");
              titleRun.setBold(true);
      
              XWPFParagraph firstParagraph = document.createParagraph();
              XWPFRun firstRun = firstParagraph.createRun();
      //        firstRun.setText("具体操作方式:");
      //        firstRun.setFontFamily("仿宋");
      //        firstRun.setFontSize(11);
              //换行
              firstParagraph.setWordWrap(true);
      
              XWPFParagraph twoParagraph = document.createParagraph();
              twoParagraph.setIndentationFirstLine(500);
              XWPFRun twoRun = twoParagraph.createRun();
      //        twoRun.setFontFamily("仿宋");
      //        twoRun.setFontSize(11);
      //        twoRun.setText("继承POI操作Word中类XWPFDocument。");
      
             // FileInputStream in = new FileInputStream("D:/1505102701_917449.png");
              FileOutputStream fos = null;
              BufferedOutputStream bos = null;
              File file = null;
      
              BASE64Decoder decoder = new BASE64Decoder();
              byte[] bfile = decoder.decodeBuffer(param.getImgBase64());
      
              file = new File(savePath,  fileName);
              fos = new FileOutputStream(file);
              bos = new BufferedOutputStream(fos);
              bos.write(bfile);
              bos.flush();
              FileInputStream in = new FileInputStream(file);
      
              byte[] ba = new byte[in.available()];
              in.read(ba);
              ByteArrayInputStream byteInputStream = new ByteArrayInputStream(ba);
              XWPFParagraph picture = document.createParagraph();
              //添加图片
              document.addPictureData(byteInputStream, CustomXWPFDocument.PICTURE_TYPE_PNG);
              //图片大小、位置
              document.createPicture(document.getAllPictures().size() - 1, 400, 300, picture);
      
      //        document.write(out);
      
      
      //        XWPFDocument document = new XWPFDocument ();//新建文档 后面NEW方法可以忽略
              ByteArrayOutputStream baos = new ByteArrayOutputStream();//二进制OutputStream
      //        document.write(baos);//文档写入流
      //        ByteArrayInputStream in2 = new ByteArrayInputStream(baos.toByteArray());//OutputStream写入InputStream二进制流
      //        out.write(in2);
      //        out.close();
      
      //        InputStream inputStream = in2;
      
              // 以流的形式下载文件。
             // InputStream fis = new BufferedInputStream(new FileInputStream(savePath));
      //        byte[] buffer = new byte[in.available()];
      //        in.read(buffer);
      //        in.close();
              // 清空response
              response.reset();
              // 设置response的Header
              response.setContentType("application/x-msdownload");
      //        response.addHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes()));
              response.addHeader("Content-Disposition", "attachment; filename=\"" + param.getWordName() + "\"");
              ServletOutputStream toClient = response.getOutputStream();
            //  response.setContentType("application/octet-stream");
      
              document.write(baos);
              toClient.write(baos.toByteArray());
      
      //        int len = 0;
      //        byte[] buffer = new byte[1024];
      //        while ((len = inputStream.read(buffer)) > 0) {
      //            toClient.write(buffer, 0, len);
      //        }
              toClient.flush();
              toClient.close();
              baos.close();
          }
      
      }
    
    
    • 工具类
      public class CustomXWPFDocument extends XWPFDocument {
          public CustomXWPFDocument(InputStream in) throws IOException {
              super(in);
          }
      
          public CustomXWPFDocument() {
              super();
          }
      
          public CustomXWPFDocument(OPCPackage pkg) throws IOException {
              super(pkg);
          }
      
          /**
           * @param id
           * @param width     宽
           * @param height    高
           * @param paragraph 段落
           */
          public void createPicture(int id, int width, int height,
                                    XWPFParagraph paragraph) {
              final int EMU = 9525;
              width *= EMU;
              height *= EMU;
              String blipId = getAllPictures().get(id).getPackageRelationship()
                      .getId();
              CTInline inline = paragraph.createRun().getCTR().addNewDrawing()
                      .addNewInline();
              String picXml = ""
                      + ""
                      + "   "
                      + "      "
                      + "         " + "            
                      + id
                      + "\" name=\"Generated\"/>"
                      + "            "
                      + "         "
                      + "         "
                      + "            
                      + blipId
                      + "\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"/>"
                      + "            "
                      + "               "
                      + "            "
                      + "         "
                      + "         "
                      + "            "
                      + "               "
                      + "               
                      + width
                      + "\" cy=\""
                      + height
                      + "\"/>"
                      + "            "
                      + "            "
                      + "               "
                      + "            "
                      + "         "
                      + "      "
                      + "   " + "";
      
              inline.addNewGraphic().addNewGraphicData();
              XmlToken xmlToken = null;
              try {
                  xmlToken = XmlToken.Factory.parse(picXml);
              } catch (XmlException xe) {
                  xe.printStackTrace();
              }
              inline.set(xmlToken);
      
              inline.setDistT(0);
              inline.setDistB(0);
              inline.setDistL(0);
              inline.setDistR(0);
      
              CTPositiveSize2D extent = inline.addNewExtent();
              extent.setCx(width);
              extent.setCy(height);
      
              CTNonVisualDrawingProps docPr = inline.addNewDocPr();
              docPr.setId(id);
              docPr.setName("图片名称");
              docPr.setDescr("描述信息");
          }
      }
      
  • 前端用get、post都可以修改接口方式就行

你可能感兴趣的:(Java,word,图片)