SpringBoot 通过File将Workbook生成的Excel文件下载到项目中
2021-01-07 16:30
标签:exists tab sts export geturl === boot stream size SpringBoot 通过File将Workbook生成的Excel文件下载到项目中 标签:exists tab sts export geturl === boot stream size 原文地址:https://www.cnblogs.com/slAmor/p/12969477.htmlExportParams exportParams = new ExportParams("错误集合", "错误集合", ExcelType.XSSF);
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, Invite.class, errorItems);
/**
* 写入到本地文件
* Springboot获取文件路径
* https://blog.csdn.net/qq_20282955/article/details/89856223
*/
File outputFile = new File(ResourceUtils.getURL("classpath:").getPath());
if (!outputFile.exists())
outputFile = new File("");
File upload = new File(outputFile.getAbsolutePath(), "download/");
if (!upload.exists())
upload.mkdirs();
FileOutputStream fos = new FileOutputStream(outputFile);
logger.error("getAbsolutePath=========>{}",outputFile.getAbsolutePath());
workbook.write(fos);// 写文件
下一篇:spring的依赖注入
文章标题:SpringBoot 通过File将Workbook生成的Excel文件下载到项目中
文章链接:http://soscw.com/index.php/essay/40743.html