File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
main/groovy/com/jameskleeh/excel/internal
test/groovy/com/jameskleeh/excel Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,9 @@ abstract class CreatesCells {
187187
188188 XSSFCell cell = nextCell()
189189 setStyle(value, cell, style)
190+ if (value == null ) {
191+ return
192+ }
190193 Closure callable = Excel . getRenderer(value. class)
191194 if (callable != null ) {
192195 cell. setCellValue((String )callable. call(value))
Original file line number Diff line number Diff line change 11package com.jameskleeh.excel
22
33import org.apache.poi.ss.usermodel.Cell
4+ import org.apache.poi.ss.usermodel.CellType
45import org.apache.poi.xssf.usermodel.XSSFSheet
56import org.apache.poi.xssf.usermodel.XSSFWorkbook
67import spock.lang.Specification
@@ -136,4 +137,22 @@ class RowSpec extends Specification {
136137 cells.next().stringCellValue == 'foox'
137138 cells.next().numericCellValue == new Double(1)
138139 }
140+
141+ void " test cell with null value" () {
142+ given:
143+ XSSFWorkbook workbook = ExcelBuilder.build {
144+ sheet {
145+ row {
146+ cell(null)
147+ }
148+ }
149+ }
150+
151+ when:
152+ Cell cell = workbook.getSheetAt(0).getRow(0).getCell(0)
153+
154+ then:
155+ noExceptionThrown()
156+ cell.getCellTypeEnum() == CellType.BLANK
157+ }
139158}
You can’t perform that action at this time.
0 commit comments