File tree Expand file tree Collapse file tree
grails-app/services/org/pih/warehouse Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -404,9 +404,11 @@ class DocumentService {
404404 void createExcelRow (HSSFSheet sheet , int rowNumber , Map dataRow ) {
405405 Row excelRow = sheet. createRow(rowNumber)
406406 dataRow. keySet(). eachWithIndex { columnName , index ->
407- def cellValue = dataRow. get(columnName) ?: " "
408- // POI can't handle objects so we need to convert all objects to strings unless they are numeric
409- if (! (cellValue instanceof Number )) {
407+ def actualValue = dataRow. get(columnName)
408+ // We can't just check the truthiness of the actualValue, because the false boolean would be evaluated to an empty string
409+ def cellValue = actualValue == null ? " " : actualValue
410+ // POI can't handle objects so we need to convert all objects to strings unless they are numeric or boolean
411+ if (! (cellValue instanceof Number ) && ! (cellValue instanceof Boolean )) {
410412 cellValue = cellValue. toString()
411413 }
412414 excelRow. createCell(index). setCellValue(cellValue)
Original file line number Diff line number Diff line change @@ -702,12 +702,14 @@ class DataService {
702702 } else if (element. defaultValue && ! value) {
703703 value = element. defaultValue
704704 }
705- properties[fieldName] = value ?: " "
705+ // We can't just check the truthiness of the value, because the false boolean would be evaluated to an empty string
706+ properties[fieldName] = value == null ? " " : value
706707 } else {
707708 // to access object value by key we must use the object.get(key) instead of object[key]
708709 // because using the object[key] will throw an error when trying to export data using the batch controller
709710 value = object. get(element) ?: element. tokenize(' .' ). inject(object) { v , k -> v?. " $k " }
710- properties[fieldName] = value ?: " "
711+ // We can't just check the truthiness of the value, because the false boolean would be evaluated to an empty string
712+ properties[fieldName] = value == null ? " " : value
711713 }
712714 }
713715 return properties
You can’t perform that action at this time.
0 commit comments