| | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.ByteArrayOutputStream; |
| | | import java.io.InputStream; |
| | | import java.net.URLEncoder; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | |
| | |
| | | return this.getFinSysTenantUserCache().get(String.valueOf(userInfo.getId())); |
| | | } |
| | | |
| | | protected String downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) throws Exception { |
| | | response.setCharacterEncoding("UTF-8"); |
| | | response.setHeader("content-Type", "application/vnd.ms-excel"); |
| | | response.setHeader("Content-Disposition", |
| | | "attachment;filename=" + URLEncoder.encode(fileName + ".xls", "UTF-8")); |
| | | protected String downLoadExcel(String fileName, Workbook workbook) throws Exception { |
| | | ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); |
| | | workbook.write(byteArrayOutputStream); |
| | | response.setHeader("Content-Length", String.valueOf(byteArrayOutputStream.size())); |
| | | |
| | | InputStream byteArrayInputStream = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); |
| | | FileInfo fileInfo = this.uploadFileToLocal(byteArrayInputStream, fileName + ".xls", "-1", |
| | | byteArrayOutputStream.size(), 0, "-1"); |
| | | String fileUrl = fileInfo.getUrl(); |
| | | workbook.close(); |
| | | |
| | | return "/file/" + fileUrl; |
| | | } |
| | | |