diff --git a/src/main/java/com/alibaba/excel/write/style/HorizontalCellStyleStrategy.java b/src/main/java/com/alibaba/excel/write/style/HorizontalCellStyleStrategy.java index 295cd556f..504570fa8 100644 --- a/src/main/java/com/alibaba/excel/write/style/HorizontalCellStyleStrategy.java +++ b/src/main/java/com/alibaba/excel/write/style/HorizontalCellStyleStrategy.java @@ -60,9 +60,10 @@ protected void setHeadCellStyle(Cell cell, Head head, Integer relativeRowIndex) @Override protected void setContentCellStyle(Cell cell, Head head, Integer relativeRowIndex) { - if (contentCellStyleList == null || contentCellStyleList.isEmpty()) { + if (contentCellStyleList == null || contentCellStyleList.isEmpty() || relativeRowIndex == null) { return; } + cell.setCellStyle(contentCellStyleList.get(relativeRowIndex % contentCellStyleList.size())); }