Skip to content

Commit

Permalink
Fixed error with:
Browse files Browse the repository at this point in the history
```
class java.lang.Integer cannot be cast to class java.lang.String
(java.lang.Integer and java.lang.String are in module java.base of
loader 'bootstrap')
```
  • Loading branch information
yamelsenih committed Jul 31, 2024
1 parent 08d0efb commit 6b26797
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/main/java/org/spin/report_engine/export/XlsxExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.NumberFormat;
Expand Down Expand Up @@ -185,27 +186,38 @@ public String export(ReportInfo reportInfo) {
org.spin.report_engine.data.Row rowValue = rows.get(rowNumber);
org.spin.report_engine.data.Cell cell = rowValue.getCell(columnInfo.getPrintFormatItemId());
int displayType = columnInfo.getDisplayTypeId();
Object obj = cell.getValue();
if(obj != null) {
Object valueasObject = cell.getValue();
if(valueasObject != null) {
if (DisplayType.isDate(displayType)) {
Timestamp value = (Timestamp)obj;
Timestamp value = (Timestamp)valueasObject;
sheetCell.setCellValue(value);
} else if (DisplayType.isNumeric(displayType)) {
double value = 0;
if (obj instanceof Number) {
value = ((Number)obj).doubleValue();
if (valueasObject instanceof Number) {
value = ((Number) valueasObject).doubleValue();
}
sheetCell.setCellValue(value);
} else if (DisplayType.YesNo == displayType) {
String value = Util.stripDiacritics(cell.getDisplayValue());
sheetCell.setCellValue(sheet.getWorkbook().getCreationHelper().createRichTextString(value));
} else {
String value = cell.getDisplayValue();
if(Util.isEmpty(value)) {
value = (String) obj;
String displayValue = cell.getDisplayValue();
if(Util.isEmpty(displayValue)) {
if(valueasObject instanceof BigDecimal) {
sheetCell.setCellValue(((BigDecimal) valueasObject).doubleValue());
} else if (valueasObject instanceof Integer) {
sheetCell.setCellValue((Integer) valueasObject);
} else if (valueasObject instanceof String) {
displayValue = (String) valueasObject;
displayValue = Util.stripDiacritics(displayValue);
sheetCell.setCellValue(sheet.getWorkbook().getCreationHelper().createRichTextString(displayValue));
} else if (valueasObject instanceof Boolean) {
sheetCell.setCellValue((Boolean) valueasObject);
} else if(valueasObject instanceof Timestamp) {
Timestamp value = (Timestamp) valueasObject;
sheetCell.setCellValue(value);
}
}
value = Util.stripDiacritics(value);
sheetCell.setCellValue(sheet.getWorkbook().getCreationHelper().createRichTextString(value));
}
}
//
Expand Down

0 comments on commit 6b26797

Please sign in to comment.