|
@@ -7,6 +7,7 @@ import cn.afterturn.easypoi.excel.entity.ExportParams;
|
|
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
|
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
|
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
|
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
|
|
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
|
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
|
|
|
|
+import cn.afterturn.easypoi.exception.excel.ExcelImportException;
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
import com.diagbot.exception.CommonException;
|
|
import com.diagbot.exception.CommonException;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -38,7 +39,7 @@ public class ExcelUtils {
|
|
}
|
|
}
|
|
|
|
|
|
public static void exportExcelDynamicCol(List<ExcelExportEntity> entityList, Collection<?> dataSet, String title, String sheetName, String fileName,
|
|
public static void exportExcelDynamicCol(List<ExcelExportEntity> entityList, Collection<?> dataSet, String title, String sheetName, String fileName,
|
|
- HttpServletResponse response) {
|
|
|
|
|
|
+ HttpServletResponse response) {
|
|
ExportParams exportParams = new ExportParams(title, sheetName);
|
|
ExportParams exportParams = new ExportParams(title, sheetName);
|
|
dynamicColExport(entityList, dataSet, fileName, response, exportParams);
|
|
dynamicColExport(entityList, dataSet, fileName, response, exportParams);
|
|
}
|
|
}
|
|
@@ -72,7 +73,7 @@ public class ExcelUtils {
|
|
|
|
|
|
private static void dynamicColExport(List<ExcelExportEntity> entityList, Collection<?> dataSet, String fileName, HttpServletResponse response,
|
|
private static void dynamicColExport(List<ExcelExportEntity> entityList, Collection<?> dataSet, String fileName, HttpServletResponse response,
|
|
ExportParams exportParams) {
|
|
ExportParams exportParams) {
|
|
- Workbook workbook = ExcelExportUtil.exportExcel(exportParams,entityList,dataSet);
|
|
|
|
|
|
+ Workbook workbook = ExcelExportUtil.exportExcel(exportParams, entityList, dataSet);
|
|
if (workbook != null) {
|
|
if (workbook != null) {
|
|
;
|
|
;
|
|
}
|
|
}
|
|
@@ -149,6 +150,8 @@ public class ExcelUtils {
|
|
} catch (NoSuchElementException e) {
|
|
} catch (NoSuchElementException e) {
|
|
// throw new NormalException("模板不能为空");
|
|
// throw new NormalException("模板不能为空");
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "模板不能为空");
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "模板不能为空");
|
|
|
|
+ } catch (ExcelImportException e) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "校验失败,请使用模板进行数据导入");
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
// throw new NormalException(e.getMessage());
|
|
// throw new NormalException(e.getMessage());
|
|
@@ -171,6 +174,8 @@ public class ExcelUtils {
|
|
} catch (NoSuchElementException e) {
|
|
} catch (NoSuchElementException e) {
|
|
// throw new NormalException("excel文件不能为空");
|
|
// throw new NormalException("excel文件不能为空");
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "excel文件不能为空");
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "excel文件不能为空");
|
|
|
|
+ } catch (ExcelImportException e) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "校验失败,请使用模板进行数据导入");
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
// throw new NormalException(e.getMessage());
|
|
// throw new NormalException(e.getMessage());
|
|
System.out.println(e.getMessage());
|
|
System.out.println(e.getMessage());
|
|
@@ -178,5 +183,4 @@ public class ExcelUtils {
|
|
}
|
|
}
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|