|
|
@ -10,6 +10,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.PositionUtils; |
|
|
|
import com.alibaba.excel.util.PositionUtils; |
|
|
|
|
|
|
|
import com.alibaba.excel.util.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Cell Handler |
|
|
|
* Cell Handler |
|
|
@ -18,6 +19,8 @@ import com.alibaba.excel.util.PositionUtils; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class CellTagHandler extends AbstractXlsxTagHandler { |
|
|
|
public class CellTagHandler extends AbstractXlsxTagHandler { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final int DEFAULT_FORMAT_INDEX = 0; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void startElement(XlsxReadContext xlsxReadContext, String name, Attributes attributes) { |
|
|
|
public void startElement(XlsxReadContext xlsxReadContext, String name, Attributes attributes) { |
|
|
|
XlsxReadSheetHolder xlsxReadSheetHolder = xlsxReadContext.xlsxReadSheetHolder(); |
|
|
|
XlsxReadSheetHolder xlsxReadSheetHolder = xlsxReadContext.xlsxReadSheetHolder(); |
|
|
@ -36,15 +39,18 @@ public class CellTagHandler extends AbstractXlsxTagHandler { |
|
|
|
|
|
|
|
|
|
|
|
// Put in data transformation information
|
|
|
|
// Put in data transformation information
|
|
|
|
String dateFormatIndex = attributes.getValue(ExcelXmlConstants.ATTRIBUTE_S); |
|
|
|
String dateFormatIndex = attributes.getValue(ExcelXmlConstants.ATTRIBUTE_S); |
|
|
|
if (dateFormatIndex != null) { |
|
|
|
Integer dateFormatIndexInteger; |
|
|
|
int dateFormatIndexInteger = Integer.parseInt(dateFormatIndex); |
|
|
|
if (StringUtils.isEmpty(dateFormatIndex)) { |
|
|
|
XSSFCellStyle xssfCellStyle = |
|
|
|
dateFormatIndexInteger = DEFAULT_FORMAT_INDEX; |
|
|
|
xlsxReadContext.xlsxReadWorkbookHolder().getStylesTable().getStyleAt(dateFormatIndexInteger); |
|
|
|
} else { |
|
|
|
int dataFormat = xssfCellStyle.getDataFormat(); |
|
|
|
dateFormatIndexInteger = Integer.parseInt(dateFormatIndex); |
|
|
|
xlsxReadSheetHolder.getTempCellData().setDataFormat(dataFormat); |
|
|
|
|
|
|
|
xlsxReadSheetHolder.getTempCellData().setDataFormatString(BuiltinFormats.getBuiltinFormat(dataFormat, |
|
|
|
|
|
|
|
xssfCellStyle.getDataFormatString(), xlsxReadSheetHolder.getGlobalConfiguration().getLocale())); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
XSSFCellStyle xssfCellStyle = |
|
|
|
|
|
|
|
xlsxReadContext.xlsxReadWorkbookHolder().getStylesTable().getStyleAt(dateFormatIndexInteger); |
|
|
|
|
|
|
|
int dataFormat = xssfCellStyle.getDataFormat(); |
|
|
|
|
|
|
|
xlsxReadSheetHolder.getTempCellData().setDataFormat(dataFormat); |
|
|
|
|
|
|
|
xlsxReadSheetHolder.getTempCellData().setDataFormatString(BuiltinFormats.getBuiltinFormat(dataFormat, |
|
|
|
|
|
|
|
xssfCellStyle.getDataFormatString(), xlsxReadSheetHolder.getGlobalConfiguration().getLocale())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|