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.
54 lines
1.6 KiB
54 lines
1.6 KiB
package com.alibaba.excel.analysis.v03.handlers; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener; |
|
import org.apache.poi.hssf.record.NumberRecord; |
|
import org.apache.poi.hssf.record.Record; |
|
|
|
import com.alibaba.excel.analysis.v03.AbstractXlsRecordHandler; |
|
import com.alibaba.excel.constant.BuiltinFormats; |
|
import com.alibaba.excel.context.XlsReadContext; |
|
import com.alibaba.excel.metadata.CellData; |
|
|
|
/** |
|
* Record handler |
|
* |
|
* @author Dan Zheng |
|
*/ |
|
public class NumberRecordHandler extends AbstractXlsRecordHandler { |
|
private FormatTrackingHSSFListener formatListener; |
|
|
|
public NumberRecordHandler(XlsReadContext analysisContext, FormatTrackingHSSFListener formatListener) { |
|
super(analysisContext); |
|
this.formatListener = formatListener; |
|
} |
|
|
|
@Override |
|
public boolean support(Record record) { |
|
return NumberRecord.sid == record.getSid(); |
|
} |
|
|
|
@Override |
|
public void processRecord(Record record) { |
|
NumberRecord numrec = (NumberRecord)record; |
|
this.row = numrec.getRow(); |
|
this.column = numrec.getColumn(); |
|
this.cellData = new CellData(BigDecimal.valueOf(numrec.getValue())); |
|
int dataFormat = formatListener.getFormatIndex(numrec); |
|
this.cellData.setDataFormat(dataFormat); |
|
this.cellData |
|
.setDataFormatString(BuiltinFormats.getBuiltinFormat(dataFormat, formatListener.getFormatString(numrec), |
|
analysisContext.readSheetHolder().getGlobalConfiguration().getLocale())); |
|
} |
|
|
|
@Override |
|
public void init() { |
|
|
|
} |
|
|
|
@Override |
|
public int getOrder() { |
|
return 0; |
|
} |
|
}
|
|
|