修复代码逻辑问题。

This commit is contained in:
hower 2023-05-29 00:09:35 +08:00
parent b6e260a2f0
commit decda097e2

View File

@ -1106,7 +1106,7 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
* @param isWriteKeyAsHead 是否将Map的Key作为表头输出如果为True第一行为表头紧接着为values * @param isWriteKeyAsHead 是否将Map的Key作为表头输出如果为True第一行为表头紧接着为values
* @return this * @return this
*/ */
public ExcelWriter writeCol(Map<?,?> colMap, boolean isWriteKeyAsHead){ public ExcelWriter writeCol(Map<?,? extends Iterable<?>> colMap, boolean isWriteKeyAsHead){
return writeCol(colMap, 0, isWriteKeyAsHead); return writeCol(colMap, 0, isWriteKeyAsHead);
} }
@ -1121,11 +1121,11 @@ public class ExcelWriter extends ExcelBase<ExcelWriter> {
* @param isWriteKeyAsHead 是否将Map的Key作为表头输出如果为True第一行为表头紧接着为values * @param isWriteKeyAsHead 是否将Map的Key作为表头输出如果为True第一行为表头紧接着为values
* @return this * @return this
*/ */
public ExcelWriter writeCol(Map<?,?> colMap, int startColIndex, boolean isWriteKeyAsHead){ public ExcelWriter writeCol(Map<?,? extends Iterable<?>> colMap, int startColIndex, boolean isWriteKeyAsHead){
for (Object k : colMap.keySet()) { for (Object k : colMap.keySet()) {
Object v = colMap.get(k); Iterable<?> v = colMap.get(k);
if(v instanceof Iterable){ if(v != null){
writeCol(isWriteKeyAsHead?k:null,startColIndex, (Iterable<?>) v, startColIndex != colMap.size() - 1); writeCol(isWriteKeyAsHead?k:null,startColIndex, v, startColIndex != colMap.size() - 1);
startColIndex ++; startColIndex ++;
} }
} }