rusackas opened a new pull request, #42601:
URL: https://github.com/apache/superset/pull/42601

   ### SUMMARY
   "Export to Pivoted Excel" runs entirely client-side: it reads the rendered 
pivot table DOM and hands it to SheetJS's `utils.table_to_book()`. By default, 
SheetJS tries to guess a type (number, date, etc.) for every cell from its 
displayed text. That guessing ignores `D3_FORMAT` and mangles anything 
formatted with non-US separators.
   
   I confirmed this directly against the real `xlsx` (SheetJS) package: with a 
Spanish `D3_FORMAT` (`.` thousands, `,` decimal), a cell rendered as 
`"1.234,56"` came out as the number `1.23456`, `"3.500"` came out as `3.5`, and 
`"12,50%"` came out as `12.5` — silently wrong values in the exported file.
   
   The fix passes `raw: true` to `table_to_book()`, so every cell keeps the 
literal text already formatted by `D3_FORMAT` in the UI instead of being 
reparsed.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   N/A (no UI change, only export contents)
   
   ### TESTING INSTRUCTIONS
   1. Set a non-US `D3_FORMAT` in `config.py`, e.g.:
      ```python
      D3_FORMAT = {
          "decimal": ",",
          "thousands": ".",
          "grouping": [3],
          "currency": ["", "€"],
      }
      ```
   2. Restart Superset, open a pivot table chart with decimal metrics.
   3. Click Download -> Export to Pivoted Excel.
   4. Before this fix: numeric cells are silently reinterpreted (wrong values, 
sometimes dates). After this fix: the exported cells match exactly what's 
rendered on screen.
   
   Also added `superset-frontend/src/utils/downloadAsPivotExcel.test.ts`, which 
pins this against the real SheetJS parsing behavior (mocking only `writeFile`, 
not `xlsx.utils`) so a regression here fails a unit test rather than only 
showing up in manually exported files.
   
   ### ADDITIONAL INFORMATION
   - [x] Has associated issue: Fixes #38555
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


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