|
|
@@ -0,0 +1,41 @@
|
|
|
+package com.izouma.nineth.utils.excel;
|
|
|
+
|
|
|
+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 com.izouma.nineth.enums.OrderStatus;
|
|
|
+
|
|
|
+public class OrderStatusConverter implements Converter<OrderStatus> {
|
|
|
+ @Override
|
|
|
+ public Class supportJavaTypeKey() {
|
|
|
+ return OrderStatus.class;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CellDataTypeEnum supportExcelTypeKey() {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public OrderStatus convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
|
|
|
+ try {
|
|
|
+ for (OrderStatus value : OrderStatus.values()) {
|
|
|
+ if (value.getDescription().equals(cellData.getStringValue())) {
|
|
|
+ return value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception ignored) {
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public CellData convertToExcelData(OrderStatus value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
|
|
|
+ if (value != null) {
|
|
|
+ return new CellData(value.getDescription());
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+}
|