Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0.5 excel空白行的处理,还是有问题 #2294

Closed
HexisLuo opened this issue Jan 19, 2022 · 2 comments
Closed

3.0.5 excel空白行的处理,还是有问题 #2294

HexisLuo opened this issue Jan 19, 2022 · 2 comments
Assignees
Labels
bug Something isn't working development completed Development completed, waiting for release

Comments

@HexisLuo
Copy link

建议先去看文档
快速开始常见问题
触发场景描述
最后一行的cellMap实际上并没有值,但是并不为空,见debug截图
debug

触发Bug的代码

   public class RowTagHandler extends AbstractXlsxTagHandler {

    @Override
    public void startElement(XlsxReadContext xlsxReadContext, String name, Attributes attributes) {
        XlsxReadSheetHolder xlsxReadSheetHolder = xlsxReadContext.xlsxReadSheetHolder();
        int rowIndex = PositionUtils.getRowByRowTagt(attributes.getValue(ExcelXmlConstants.ATTRIBUTE_R),
            xlsxReadSheetHolder.getRowIndex());
        Integer lastRowIndex = xlsxReadContext.readSheetHolder().getRowIndex();
        while (lastRowIndex + 1 < rowIndex) {
            xlsxReadContext.readRowHolder(new ReadRowHolder(lastRowIndex + 1, RowTypeEnum.EMPTY,
                xlsxReadSheetHolder.getGlobalConfiguration(), new LinkedHashMap<Integer, Cell>()));
            xlsxReadContext.analysisEventProcessor().endRow(xlsxReadContext);
            xlsxReadSheetHolder.setColumnIndex(null);
            xlsxReadSheetHolder.setCellMap(new LinkedHashMap<Integer, Cell>());
            lastRowIndex++;
        }
        xlsxReadSheetHolder.setRowIndex(rowIndex);
    }

    @Override
    public void endElement(XlsxReadContext xlsxReadContext, String name) {
        XlsxReadSheetHolder xlsxReadSheetHolder = xlsxReadContext.xlsxReadSheetHolder();
// ###################这里判断EMPTY还是DATA不严谨
        RowTypeEnum rowType = MapUtils.isEmpty(xlsxReadSheetHolder.getCellMap()) ? RowTypeEnum.EMPTY : RowTypeEnum.DATA;
        xlsxReadContext.readRowHolder(new ReadRowHolder(xlsxReadSheetHolder.getRowIndex(), rowType,
            xlsxReadSheetHolder.getGlobalConfiguration(), xlsxReadSheetHolder.getCellMap()));
        xlsxReadContext.analysisEventProcessor().endRow(xlsxReadContext);
        xlsxReadSheetHolder.setColumnIndex(null);
        xlsxReadSheetHolder.setCellMap(new LinkedHashMap<>());
    }

}

提示的异常或者没有达到的效果
test.xlsx

@HexisLuo HexisLuo added the bug Something isn't working label Jan 19, 2022
@zhuangjiaju zhuangjiaju added the development completed Development completed, waiting for release label Feb 10, 2022
@zhuangjiaju
Copy link
Collaborator

该问题已经在3.1.0+版本里面解决,最新版本:Maven central

@simplesboy
Copy link

对于csv的读取我看在3.1.1的版本里还是有这个问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working development completed Development completed, waiting for release
Projects
None yet
Development

No branches or pull requests

3 participants