Search in sources :

Example 1 with ReadCache

use of com.alibaba.excel.cache.ReadCache in project easyexcel by alibaba.

the class LabelSstRecordHandler method processRecord.

@Override
public void processRecord(XlsReadContext xlsReadContext, Record record) {
    LabelSSTRecord lsrec = (LabelSSTRecord) record;
    ReadCache readCache = xlsReadContext.readWorkbookHolder().getReadCache();
    Map<Integer, Cell> cellMap = xlsReadContext.xlsReadSheetHolder().getCellMap();
    if (readCache == null) {
        cellMap.put((int) lsrec.getColumn(), ReadCellData.newEmptyInstance(lsrec.getRow(), (int) lsrec.getColumn()));
        return;
    }
    String data = readCache.get(lsrec.getSSTIndex());
    if (data == null) {
        cellMap.put((int) lsrec.getColumn(), ReadCellData.newEmptyInstance(lsrec.getRow(), (int) lsrec.getColumn()));
        return;
    }
    if (xlsReadContext.currentReadHolder().globalConfiguration().getAutoTrim()) {
        data = data.trim();
    }
    cellMap.put((int) lsrec.getColumn(), ReadCellData.newInstance(data, lsrec.getRow(), (int) lsrec.getColumn()));
    xlsReadContext.xlsReadSheetHolder().setTempRowType(RowTypeEnum.DATA);
}
Also used : LabelSSTRecord(org.apache.poi.hssf.record.LabelSSTRecord) ReadCache(com.alibaba.excel.cache.ReadCache) Cell(com.alibaba.excel.metadata.Cell)

Example 2 with ReadCache

use of com.alibaba.excel.cache.ReadCache in project easyexcel by alibaba.

the class XlsxSaxAnalyser method defaultReadCache.

private void defaultReadCache(XlsxReadWorkbookHolder xlsxReadWorkbookHolder, PackagePart sharedStringsTablePackagePart) {
    ReadCache readCache = xlsxReadWorkbookHolder.getReadCacheSelector().readCache(sharedStringsTablePackagePart);
    xlsxReadWorkbookHolder.setReadCache(readCache);
    readCache.init(xlsxReadContext);
}
Also used : ReadCache(com.alibaba.excel.cache.ReadCache)

Aggregations

ReadCache (com.alibaba.excel.cache.ReadCache)2 Cell (com.alibaba.excel.metadata.Cell)1 LabelSSTRecord (org.apache.poi.hssf.record.LabelSSTRecord)1