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

   **Summary**
   `
   After upgrading from Apache POI 5.5.1 to 6.0.0, cells formatted with 
standard two-part percentage formats containing positive and negative sections 
(e.g., 0.0%;[Red](0.0%) or 0.0%;(0.0%)) are incorrectly multiplied by 10000 
(100x larger than expected). For example, a numeric value of 0.296 was 
formatted as 29.6% in 5.5.1, but in 6.0.0 it is formatted as 2960.0%.
   `
   
   import org.apache.poi.ss.usermodel.DataFormatter;
   import java.util.Locale;
   
   public class PoiPercentBugTest {
       public static void main(String[] args) {
           DataFormatter formatter = new DataFormatter(Locale.US);
           double value = 0.296;
   
           // 1-part format: works as expected -> "29.6%"
           System.out.println("1-part: " + 
formatter.formatRawCellContents(value, -1, "0.0%"));
   
           // 2-part format: BUG in 6.0.0 -> prints "2960.0%" instead of "29.6%"
           System.out.println("2-part (Red): " + 
formatter.formatRawCellContents(value, -1, "0.0%;[Red](0.0%)"));
           System.out.println("2-part:       " + 
formatter.formatRawCellContents(value, -1, "0.0%;(0.0%)"));
   
           // 3-part format: works as expected (delegates to CellFormat) -> 
"29.6%"
           System.out.println("3-part: " + 
formatter.formatRawCellContents(value, -1, "0.0%;(0.0%);\"-\""));
       }
   }
   
   **Expected output:**
   1-part: 29.6%
   2-part (Red): 29.6%
   2-part:       29.6%
   3-part: 29.6%
   
   **Actual output in POI 6.0.0:**
   1-part: 29.6%
   2-part (Red): 2960.0%
   2-part:       2960.0%
   3-part: 29.6%
   
   
   


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