예제 #1
0
 public static void exportExcel(ExportExcelParam exportParam) throws IOException {
   String fileName = assureExcelSuffix(exportParam.fileName);
   FileOutputStream outputStream = new FileOutputStream(fileName);
   ExcelIO.INSTANCE
       .get()
       .setHeader(exportParam.headers)
       .setSheetName(exportParam.sheetName)
       .exportTo(outputStream, exportParam.dataList);
   outputStream.flush();
   outputStream.close();
 }
예제 #2
0
 public static void exportExcel(HttpServletResponse response, ExportExcelParam excel)
     throws IOException {
   String fileName = assureExcelSuffix(excel.fileName);
   response.setContentType("application/msexcel");
   response.setHeader(
       "Content-Disposition",
       String.format("attachment; filename=\"%s\";", URLEncoder.encode(fileName, "utf-8")));
   ServletOutputStream outputStream = response.getOutputStream();
   ExcelIO.INSTANCE
       .get()
       .setHeader(excel.headers)
       .setSheetName(excel.sheetName)
       .exportTo(outputStream, excel.dataList);
   outputStream.flush();
   outputStream.close();
 }