赞
踩
package com.ztw.common.util; import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.ExcelImportUtil; import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.ImportParams; import cn.afterturn.easypoi.excel.entity.enmus.ExcelType; import org.apache.commons.lang3.StringUtils; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFDateUtil; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Workbook; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; @Component public class ExcelUtil { private static String excelPath; /* @Value("${excelPath}") public void setExcelPath(String excelPath) { ExeclUtil.excelPath = excelPath; }*/ public static void download(HttpServletRequest request, HttpServletResponse response, String title, Workbook workbook) throws IOException { String path = excelPath + "/ExcelData//" + title + ".xls"; File file = new File(path); //判断目标文件所在的目录是否存在 if (!file.getParentFile().exists()) { file.getParentFile().mkdirs(); } FileOutputStream fos = new FileOutputStream(new File(path)); workbook.write(fos); workbook.close(); fos.close(); response.setHeader("content-type", "application/octet-stream"); respon
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。