chpasha opened a new issue, #977:
URL: https://github.com/apache/poi/issues/977

   Library version 5.5.1:
   
   cell, having number cell style defined as 
   `#.##0,00 _€;[Red]-#.##0,00 _€ `
   returns 
   `#,##0.00_);[Red](#,##0.00) `
   on call to cell.getCellStyle().getDataFormatString - it corresponds to 
built-in style 40 (0x28)
   negative values, formatted with this format by call to 
   `DataFormatter.formatRawCellContents`
   return positive values in round brackets, so the value is effectively 
corrupted while using streaming event mode with XSSFSheetXMLHandler.
   
   Here is the full code and sample file 
[poi_formatting_problem.xls](https://github.com/user-attachments/files/24216439/poi_formatting_problem.xls)
 to reproduce the issue
   ```
   
   try (var wb = WorkbookFactory.create(new File("poi_formatting_problem.xls")))
                {
   
                        //Style (as seen in Excel) #.##0,00 _€;[Red]-#.##0,00 _€
                        //is converted to #,##0.00_);[Red](#,##0.00)
                        var sheet = wb.getSheetAt(0);
                        var row = sheet.getRow(0);
                        var cell = row.getCell(0);
                        var str = new 
DataFormatter().formatRawCellContents(cell.getNumericCellValue(), 
cell.getCellStyle().getDataFormat(), 
   
   cell.getCellStyle().getDataFormatString());
                        //str is (378.13) instead of -378.13
                }
   
   ```
    


-- 
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]

Reply via email to