|
|
|
@@ -22,6 +22,9 @@ import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.File; |
|
|
|
import java.io.IOException; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.NoSuchElementException; |
|
|
|
@@ -30,6 +33,20 @@ import java.util.NoSuchElementException; |
|
|
|
public class ExcelService { |
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
|
|
|
|
|
|
|
public void exportExcel(Map<String,String> titleMap,List<Map<String, Object>> list, String fileName,String sheetName, HttpServletResponse response) { |
|
|
|
//defaultExport(list, fileName, response); |
|
|
|
List<ExcelExportEntity> modelList = new ArrayList<ExcelExportEntity>(); |
|
|
|
ExcelExportEntity excelentity = null; |
|
|
|
for (Iterator<String> it = titleMap.keySet().iterator();it.hasNext();) { |
|
|
|
String titleKey = it.next(); |
|
|
|
String title = titleMap.get(titleKey); |
|
|
|
excelentity = new ExcelExportEntity(title, titleKey); |
|
|
|
excelentity.setWidth(20); |
|
|
|
excelentity.setHeight(10); |
|
|
|
modelList.add(excelentity); |
|
|
|
} |
|
|
|
exportExcel(modelList,list,null,sheetName,fileName,true,response); |
|
|
|
} |
|
|
|
|
|
|
|
public void exportExcel(List<ExcelExportEntity> headList,List<?> dataList, String title, String sheetName, String fileName, boolean isCreateHeader, HttpServletResponse response) |
|
|
|
{ |
|
|
|
@@ -78,10 +95,6 @@ public class ExcelService { |
|
|
|
defaultExportCsv(list, pojoClass, fileName, response, new CsvExportParams(), template); |
|
|
|
} |
|
|
|
|
|
|
|
public void exportExcel(List<Map<String, Object>> list, String fileName, HttpServletResponse response) { |
|
|
|
defaultExport(list, fileName, response); |
|
|
|
} |
|
|
|
|
|
|
|
private void defaultExport(List<ExcelExportEntity> entityList, List<?> dataList, String fileName, HttpServletResponse response, ExportParams exportParams, boolean template) { |
|
|
|
Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, dataList); |
|
|
|
if (workbook != null) { |
|
|
|
|