excel导出带图片

第一步:pom.xml 中引入依赖

<properties>
        <poi.version>3.15</poi.version>
        <easypoi.version>3.3.0</easypoi.version>
    </properties>
<!-- POI -->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>${poi.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>${poi.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml-schemas</artifactId>
            <version>${poi.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-scratchpad</artifactId>
            <version>${poi.version}</version>
        </dependency>
        <dependency>
            <groupId>cn.afterturn</groupId>
            <artifactId>easypoi-web</artifactId>
            <version>${easypoi.version}</version>
        </dependency>

第二步:创建模板


image.png

第三步:创建模板数据

 List<Map<String,Object>> list = new ArrayList<>();
 Map<String, Object> total = new HashMap<>();
 total.put("list", list );
 Workbook workbook = ExcelExportUtil.exportExcel(params, total);

 response.setContentType("multipart/form-data");
 response.setCharacterEncoding("utf-8");
 response.setHeader("Content-disposition", "attachment;filename=" + "default" + ExcelTypeEnum.XLSX.getValue());
 workbook.write(response.getOutputStream());

知识点:
!fe: 遍历数据不创建row。
list 自定义的名称,表示表达式中的数据集合,由代码以list为键,从Map<String, Object>中获取值的集合。
t 预定义值,表示集合中的任意对象。

]] 换行符 多行遍历导出。

‘’ 单引号表示常量值 ‘’ 比如’1’ 那么输出的就是 1

https://blog.csdn.net/u012441819/article/details/96828044

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容