提交 df761896 编写于 作者: Z zhuangjiaju

优化读写逻辑

上级 89245cd0
...@@ -86,12 +86,12 @@ public class ExcelWriteHeadProperty extends ExcelHeadProperty { ...@@ -86,12 +86,12 @@ public class ExcelWriteHeadProperty extends ExcelHeadProperty {
} }
alreadyRangeSet.add(i + "-" + j); alreadyRangeSet.add(i + "-" + j);
String headName = headNameList.get(j); String headName = headNameList.get(j);
int endX = i; int lastCol = i;
int endY = j; int lastRow = j;
for (int k = i + 1; k < headList.size(); k++) { for (int k = i + 1; k < headList.size(); k++) {
if (headList.get(k).getHeadNameList().get(j).equals(headName)) { if (headList.get(k).getHeadNameList().get(j).equals(headName)) {
alreadyRangeSet.add(k + "-" + j); alreadyRangeSet.add(k + "-" + j);
endX = k; lastCol = k;
} else { } else {
break; break;
} }
...@@ -99,20 +99,20 @@ public class ExcelWriteHeadProperty extends ExcelHeadProperty { ...@@ -99,20 +99,20 @@ public class ExcelWriteHeadProperty extends ExcelHeadProperty {
Set<String> tempAlreadyRangeSet = new HashSet<String>(); Set<String> tempAlreadyRangeSet = new HashSet<String>();
outer: outer:
for (int k = j + 1; k < headNameList.size(); k++) { for (int k = j + 1; k < headNameList.size(); k++) {
for (int l = i; l <= endX; l++) { for (int l = i; l <= lastCol; l++) {
if (headList.get(l).getHeadNameList().get(k).equals(headName)) { if (headList.get(l).getHeadNameList().get(k).equals(headName)) {
tempAlreadyRangeSet.add(l + "-" + k); tempAlreadyRangeSet.add(l + "-" + k);
} else { } else {
break outer; break outer;
} }
} }
endY = k; lastRow = k;
alreadyRangeSet.addAll(tempAlreadyRangeSet); alreadyRangeSet.addAll(tempAlreadyRangeSet);
} }
if (j == endY && i == endX) { if (j == lastRow && i == lastCol) {
continue; continue;
} }
cellRangeList.add(new CellRange(j, endY, i, endX)); cellRangeList.add(new CellRange(j, lastRow, i, lastCol));
} }
} }
return cellRangeList; return cellRangeList;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册