yupeng
2025-04-15 cd3d553f88fb74f1b15eca9fd50b4318956fb01d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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>
 * 文件列表 前端控制器
 * </p>
 *
 * @author yupeng
 * @since 2025-03-05
 */
@RestController
@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();
    }
 
}