Aias00 opened a new issue, #973: URL: https://github.com/apache/fesod/issues/973
### Search before asking - [x] I searched in the [issues](https://github.com/apache/fesod/issues) and found nothing similar. ### Fesod version current main (50a6b5b) ### JDK version Temurin 25 (code path is version-independent, affects 8+) ### Operating system Linux (not OS-specific) ### Steps To Reproduce Writing a `Calendar` value to a `CsvCell` via the POI `Cell` API silently produces an empty field instead of the date. ```java Calendar cal = Calendar.getInstance(); cal.set(2024, Calendar.JANUARY, 15, 12, 30, 45); cal.set(Calendar.MILLISECOND, 0); try (Writer writer = Files.newBufferedWriter(csvFile.toPath(), StandardCharsets.UTF_8)) { CsvWorkbook workbook = new CsvWorkbook(writer, null, false, false, StandardCharsets.UTF_8, false); CsvSheet sheet = (CsvSheet) workbook.createSheet(); CsvRow row = (CsvRow) sheet.createRow(0); Cell cell = row.createCell(0, CellType.NUMERIC); cell.setCellValue(cal); sheet.close(); } // csvFile content is an empty field instead of "2024-01-15 12:30:45" ``` ### Current Behavior The CSV cell is written as an empty field. The `Calendar` value is silently lost — no exception is thrown. ### Expected Behavior The cell should be written as a date (`2024-01-15 12:30:45` by default), the same way `setCellValue(java.util.Date)` and `setCellValue(java.time.LocalDateTime)` behave on a `CsvCell`. ### Anything else? Root cause: `CsvCell.setCellValueImpl(Calendar)` sets `dateValue` and `cellType = NUMERIC` but, unlike its sibling setters, does **not** set `numericCellType = NumericCellTypeEnum.DATE`: https://github.com/apache/fesod/blob/main/fesod-sheet/src/main/java/org/apache/fesod/sheet/metadata/csv/CsvCell.java#L186-L193 ```java @Override protected void setCellValueImpl(Calendar value) { if (value == null) { return; } this.dateValue = LocalDateTime.ofInstant(value.toInstant(), ZoneId.systemDefault()); this.cellType = CellType.NUMERIC; // missing: this.numericCellType = NumericCellTypeEnum.DATE; } ``` The sibling `Date` setter (a few lines above) and `LocalDateTime` setter both set it: ```java this.cellType = CellType.NUMERIC; this.numericCellType = NumericCellTypeEnum.DATE; ``` In `CsvSheet.buildCellValue` the `NUMERIC` branch dispatches on `csvCell.getNumericCellType() == NumericCellTypeEnum.DATE`; when it is not set, the cell takes the number branch, finds `numberValue` is `null`, and returns `null`, producing an empty field. Adding the missing line fixes it: ```java this.numericCellType = NumericCellTypeEnum.DATE; ``` ### Are you willing to submit a PR? - [x] I'm willing to submit a PR! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
