EasyPOI后台导出空模板

导出带数据的或者导出空模板都一样。。。
代码:

public void ExcelCllocationsTem(HttpServletResponse response) throws IOException {
        Workbook workbook = null;
        String sheetName = "模板";
        String filename = "设备导入模板.xlsx";
        response.setHeader("content-Type", "application/vnd.ms-excel");
        response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
        workbook = ExcelExportUtil.exportExcel(new ExportParams(null, sheetName, ExcelType.XSSF), CllocationsVOImExcel.class, new ArrayList<>());
        // 告诉浏览器用什么软件可以打开此文件
        response.setHeader("content-Type", "application/vnd.ms-excel");
        // 下载文件的默认名称
        response.setHeader("Content-Disposition", "attachment;filename*=utf-8''" + URLEncoder.encode(filename, "UTF-8"));
        response.setCharacterEncoding("UTF-8");
        workbook.write(response.getOutputStream());
    }

因为我的模板很简单就2列,所以就如下
实体类:

@Data
public class CllocationsVOImExcel implements Serializable {
    /***
     * 设备描述
     */
    @Excel(name = "设备名称")
    private String description;
    /***
     * 设备类型
     */
    @Excel(name = "节点类型")
    private String craft;
    /***
     * 父节点
     */
    private String parent;
}

你可能感兴趣的:(笔记,poi)