美文网首页
spring boot使用apache poi读写word

spring boot使用apache poi读写word

作者: 刘书生 | 来源:发表于2019-07-31 16:06 被阅读0次

maven依赖

<dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>${poi.version}</version>
        </dependency>

测试方法

    @Test
    public void testPoiWord() throws IOException {
        FileInputStream tempFileInputStream = new FileInputStream(word);
        FileOutputStream outputStream = new FileOutputStream("C:\\BaiduNetdiskDownload\\生成\\first.docx");
        //docx
        XWPFDocument document = new XWPFDocument(tempFileInputStream);
        // 读取文本内容
        CTDocument1 document1 = document.getDocument();
        document.write(outputStream);
        System.out.println(document1);
    }

相关文章

网友评论

      本文标题:spring boot使用apache poi读写word

      本文链接:https://www.haomeiwen.com/subject/ahstdctx.html