| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import org.apache.poi.openxml4j.exceptions.InvalidFormatException; |
| | | import org.apache.poi.util.Units; |
| | | import org.apache.poi.xwpf.usermodel.*; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RequestMapping("/sys-file") |
| | | public class SysFileController { |
| | | |
| | | public static void main(String[] args) throws IOException, InvalidFormatException { |
| | | XWPFDocument document= new XWPFDocument(); |
| | | FileOutputStream out = new FileOutputStream(new File("D:\\a.docx")); |
| | | //基本信息表格 |
| | | XWPFParagraph pic = document.createParagraph(); |
| | | XWPFRun picRun = pic.createRun(); |
| | | picRun.addPicture( |
| | | new FileInputStream("C:\\Users\\Admin\\Pictures\\Camera Roll\\1.jpg"),XWPFDocument.PICTURE_TYPE_JPEG, |
| | | "C:\\Users\\Admin\\Pictures\\Camera Roll\\1.jpg", |
| | | Units.toEMU(60), |
| | | Units.toEMU(30) |
| | | ); |
| | | |
| | | document.write(out); |
| | | out.close(); |
| | | } |
| | | |
| | | } |
| | | |