forked from fanruan/easyexcel
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.4 KiB
39 lines
1.4 KiB
package com.alibaba.excel.analysis.v07.handlers; |
|
|
|
import com.alibaba.excel.context.xlsx.XlsxReadContext; |
|
import com.alibaba.excel.enums.CellDataTypeEnum; |
|
import com.alibaba.excel.metadata.CellData; |
|
import com.alibaba.excel.util.StringUtils; |
|
|
|
/** |
|
* Cell Value Handler |
|
* |
|
* @author jipengfei |
|
*/ |
|
public class CellValueTagHandler extends AbstractCellValueTagHandler { |
|
|
|
@Override |
|
protected void setStringValue(XlsxReadContext xlsxReadContext) { |
|
// Have to go "sharedStrings.xml" and get it |
|
CellData tempCellData = xlsxReadContext.xlsxReadSheetHolder().getTempCellData(); |
|
switch (tempCellData.getType()) { |
|
case STRING: |
|
// In some cases, although cell type is a string, it may be an empty tag |
|
if(StringUtils.isEmpty(tempCellData.getStringValue())){ |
|
break; |
|
} |
|
String stringValue = xlsxReadContext.readWorkbookHolder().getReadCache() |
|
.get(Integer.valueOf(tempCellData.getStringValue())); |
|
if (stringValue != null && xlsxReadContext.currentReadHolder().globalConfiguration().getAutoTrim()) { |
|
stringValue = stringValue.trim(); |
|
} |
|
tempCellData.setStringValue(stringValue); |
|
break; |
|
case DIRECT_STRING: |
|
tempCellData.setType(CellDataTypeEnum.STRING); |
|
break; |
|
default: |
|
} |
|
} |
|
|
|
}
|
|
|