|
|
@ -7,6 +7,7 @@ import com.alibaba.excel.enums.CellDataTypeEnum; |
|
|
|
import com.alibaba.excel.metadata.CellData; |
|
|
|
import com.alibaba.excel.metadata.CellData; |
|
|
|
import com.alibaba.excel.read.metadata.holder.xlsx.XlsxReadSheetHolder; |
|
|
|
import com.alibaba.excel.read.metadata.holder.xlsx.XlsxReadSheetHolder; |
|
|
|
import com.alibaba.excel.util.BooleanUtils; |
|
|
|
import com.alibaba.excel.util.BooleanUtils; |
|
|
|
|
|
|
|
import com.alibaba.excel.util.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Cell Value Handler |
|
|
|
* Cell Value Handler |
|
|
@ -20,6 +21,7 @@ public abstract class AbstractCellValueTagHandler extends AbstractXlsxTagHandler |
|
|
|
XlsxReadSheetHolder xlsxReadSheetHolder = xlsxReadContext.xlsxReadSheetHolder(); |
|
|
|
XlsxReadSheetHolder xlsxReadSheetHolder = xlsxReadContext.xlsxReadSheetHolder(); |
|
|
|
CellData tempCellData = xlsxReadSheetHolder.getTempCellData(); |
|
|
|
CellData tempCellData = xlsxReadSheetHolder.getTempCellData(); |
|
|
|
StringBuilder tempData = xlsxReadSheetHolder.getTempData(); |
|
|
|
StringBuilder tempData = xlsxReadSheetHolder.getTempData(); |
|
|
|
|
|
|
|
String tempDataString = tempData.toString(); |
|
|
|
CellDataTypeEnum oldType = tempCellData.getType(); |
|
|
|
CellDataTypeEnum oldType = tempCellData.getType(); |
|
|
|
switch (oldType) { |
|
|
|
switch (oldType) { |
|
|
|
case DIRECT_STRING: |
|
|
|
case DIRECT_STRING: |
|
|
@ -28,10 +30,18 @@ public abstract class AbstractCellValueTagHandler extends AbstractXlsxTagHandler |
|
|
|
tempCellData.setStringValue(tempData.toString()); |
|
|
|
tempCellData.setStringValue(tempData.toString()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case BOOLEAN: |
|
|
|
case BOOLEAN: |
|
|
|
|
|
|
|
if(StringUtils.isEmpty(tempDataString)){ |
|
|
|
|
|
|
|
tempCellData.setType(CellDataTypeEnum.EMPTY); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
tempCellData.setBooleanValue(BooleanUtils.valueOf(tempData.toString())); |
|
|
|
tempCellData.setBooleanValue(BooleanUtils.valueOf(tempData.toString())); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case NUMBER: |
|
|
|
case NUMBER: |
|
|
|
case EMPTY: |
|
|
|
case EMPTY: |
|
|
|
|
|
|
|
if(StringUtils.isEmpty(tempDataString)){ |
|
|
|
|
|
|
|
tempCellData.setType(CellDataTypeEnum.EMPTY); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
tempCellData.setType(CellDataTypeEnum.NUMBER); |
|
|
|
tempCellData.setType(CellDataTypeEnum.NUMBER); |
|
|
|
tempCellData.setNumberValue(new BigDecimal(tempData.toString())); |
|
|
|
tempCellData.setNumberValue(new BigDecimal(tempData.toString())); |
|
|
|
break; |
|
|
|
break; |
|
|
|