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

通过模板导出时传入list<list<object>>数据,导出的数据少了最后一列 #526

Closed
dieeman opened this issue Sep 3, 2019 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@dieeman
Copy link

dieeman commented Sep 3, 2019

No description provided.

@dieeman dieeman added the help wanted Extra attention is needed label Sep 3, 2019
@zhuangjiaju
Copy link
Collaborator

请提供源代码

@dieeman
Copy link
Author

dieeman commented Sep 4, 2019

private void addBasicTypeToExcel(List oneRowData, Row row, int relativeRowIndex) {
if (CollectionUtils.isEmpty(oneRowData)) {
return;
}
Map<Integer, Head> headMap = context.currentWriteHolder().excelWriteHeadProperty().getHeadMap();
int dataIndex = 0;
int cellIndex = 0;
for (Map.Entry<Integer, Head> entry : headMap.entrySet()) {
if (dataIndex >= oneRowData.size()) {
return;
}
cellIndex = entry.getKey();
Head head = entry.getValue();
doAddBasicTypeToExcel(oneRowData, head, row, relativeRowIndex, dataIndex++, cellIndex);
}
// Finish
if (dataIndex >= oneRowData.size()) {
return;
}
if (cellIndex != 0) {
cellIndex++;
}
for (int i = 0; i < oneRowData.size() - dataIndex; i++) {//此处减去dataindex后遍历次数减少无法全部遍历出oneRowData中的数据
doAddBasicTypeToExcel(oneRowData, null, row, relativeRowIndex, dataIndex++, cellIndex++);
}
}

@dieeman
Copy link
Author

dieeman commented Sep 4, 2019

还有当oneRowData.get(i)为null时,获取不到oneRowData.get(i)的class,会报空指针

@zhuangjiaju zhuangjiaju reopened this Sep 4, 2019
@zhuangjiaju
Copy link
Collaborator

还有当oneRowData.get(i)为null时,获取不到oneRowData.get(i)的class,会报空指针

这个请提供测试数据

@zhuangjiaju
Copy link
Collaborator

已经在2.0.0-beat4 修复 非常感谢您的意见

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants