|
|
|
@ -429,9 +429,8 @@ public class ExcelUtil<T>
|
|
|
|
|
* @param list 导出数据集合 |
|
|
|
|
* @param sheetName 工作表的名称 |
|
|
|
|
* @return 结果 |
|
|
|
|
* @throws IOException |
|
|
|
|
*/ |
|
|
|
|
public void exportExcel(HttpServletResponse response, List<T> list, String sheetName)throws IOException |
|
|
|
|
public void exportExcel(HttpServletResponse response, List<T> list, String sheetName) |
|
|
|
|
{ |
|
|
|
|
exportExcel(response, list, sheetName, StringUtils.EMPTY); |
|
|
|
|
} |
|
|
|
@ -444,14 +443,13 @@ public class ExcelUtil<T>
|
|
|
|
|
* @param sheetName 工作表的名称 |
|
|
|
|
* @param title 标题 |
|
|
|
|
* @return 结果 |
|
|
|
|
* @throws IOException |
|
|
|
|
*/ |
|
|
|
|
public void exportExcel(HttpServletResponse response, List<T> list, String sheetName, String title) throws IOException |
|
|
|
|
public void exportExcel(HttpServletResponse response, List<T> list, String sheetName, String title) |
|
|
|
|
{ |
|
|
|
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
|
|
|
|
response.setCharacterEncoding("utf-8"); |
|
|
|
|
this.init(list, sheetName, title, Type.EXPORT); |
|
|
|
|
exportExcel(response.getOutputStream()); |
|
|
|
|
exportExcel(response); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -484,7 +482,7 @@ public class ExcelUtil<T>
|
|
|
|
|
* @param sheetName 工作表的名称 |
|
|
|
|
* @return 结果 |
|
|
|
|
*/ |
|
|
|
|
public void importTemplateExcel(HttpServletResponse response, String sheetName) throws IOException |
|
|
|
|
public void importTemplateExcel(HttpServletResponse response, String sheetName) |
|
|
|
|
{ |
|
|
|
|
importTemplateExcel(response, sheetName, StringUtils.EMPTY); |
|
|
|
|
} |
|
|
|
@ -496,12 +494,12 @@ public class ExcelUtil<T>
|
|
|
|
|
* @param title 标题 |
|
|
|
|
* @return 结果 |
|
|
|
|
*/ |
|
|
|
|
public void importTemplateExcel(HttpServletResponse response, String sheetName, String title) throws IOException |
|
|
|
|
public void importTemplateExcel(HttpServletResponse response, String sheetName, String title) |
|
|
|
|
{ |
|
|
|
|
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); |
|
|
|
|
response.setCharacterEncoding("utf-8"); |
|
|
|
|
this.init(null, sheetName, title, Type.IMPORT); |
|
|
|
|
exportExcel(response.getOutputStream()); |
|
|
|
|
exportExcel(response); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -509,12 +507,12 @@ public class ExcelUtil<T>
|
|
|
|
|
* |
|
|
|
|
* @return 结果 |
|
|
|
|
*/ |
|
|
|
|
public void exportExcel(OutputStream out) |
|
|
|
|
public void exportExcel(HttpServletResponse response) |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
writeSheet(); |
|
|
|
|
wb.write(out); |
|
|
|
|
wb.write(response.getOutputStream()); |
|
|
|
|
} |
|
|
|
|
catch (Exception e) |
|
|
|
|
{ |
|
|
|
@ -523,7 +521,6 @@ public class ExcelUtil<T>
|
|
|
|
|
finally |
|
|
|
|
{ |
|
|
|
|
IOUtils.closeQuietly(wb); |
|
|
|
|
IOUtils.closeQuietly(out); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|