|
@@ -0,0 +1,43 @@
|
|
|
|
+package org.springblade.meter.config;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+import com.alibaba.excel.converters.Converter;
|
|
|
|
+import com.alibaba.excel.enums.CellDataTypeEnum;
|
|
|
|
+import com.alibaba.excel.metadata.CellData;
|
|
|
|
+import com.alibaba.excel.metadata.GlobalConfiguration;
|
|
|
|
+import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
|
|
|
+
|
|
|
|
+import java.util.Objects;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @Param EasyExcel配置类型转换
|
|
|
|
+ * @Author wangwl
|
|
|
|
+ * @Date 2024/4/18 14:54
|
|
|
|
+ **/
|
|
|
|
+public class IsConverter implements Converter<Integer> {
|
|
|
|
+ //写入数据时,将excel单元格数据转化为java
|
|
|
|
+ @Override
|
|
|
|
+ public Integer convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
|
|
|
|
+ String data = cellData.getStringValue();
|
|
|
|
+ if (data != null && Objects.equals(data, "是")) {
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //导出数据到excel
|
|
|
|
+ @Override
|
|
|
|
+ public CellData convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
|
|
|
|
+ return new CellData(value == 1 ? "是" : "否");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Class<?> supportJavaTypeKey() {
|
|
|
|
+ return String.class;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public CellDataTypeEnum supportExcelTypeKey() {
|
|
|
|
+ return CellDataTypeEnum.STRING;
|
|
|
|
+ }
|
|
|
|
+}
|