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

   # Pull request (Apache Superset)
   
   **Branch:** `feature/excel-timezone-naive-export`  
   **Title:** `fix(excel): keep wall-clock datetimes when exporting timezones`
   
   Use this body with `.github/PULL_REQUEST_TEMPLATE.md`. Attach screenshots 
from
   `screenshots/before/` and `screenshots/after/`.
   
   ---
   
   ### SUMMARY
   
   `DataFrame.to_excel` cannot store timezone-aware timestamps. On `master`,
   Superset stringifies those columns (e.g. `2024-03-07 21:00:00+00:00`). Excel
   then does not treat them as dates, and a tz-aware pivot index can fail the
   export entirely.
   
   Converting with `tz_convert(None)` would shift wall-clock time into UTC and 
can
   move the calendar date (midnight in UTC+3 becomes the previous evening).
   
   This change strips the offset with `tz_localize(None)` / 
`replace(tzinfo=None)`
   on values, column labels, and the row index so the Excel cell is a naive
   datetime matching Explore. `RangeIndex` is left unchanged so an extra index
   column is not written. Numeric and tz-naive columns are untouched. Formula
   quoting is unchanged.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   **Before (`master`):** Table XLSX, column `event_ts_msk`. Cell preview shows 
a
   string with `+00:00`. LibreOffice “Format cells” is Number / Standard, not
   Date.
   <img width="1917" height="1033" alt="Снимок экрана от 2026-09-16 23-25-13" 
src="https://github.com/user-attachments/assets/598310f4-efe5-40dd-808e-89de55c6cf3a";
 />
   
   **After (`feature/excel-timezone-naive-export`):** Same chart, same download.
   Value matches Explore wall-clock (no extra UTC shift). Cell type is Date /
   Date-time. `+00:00` is gone.
   <img width="1917" height="1033" alt="Снимок экрана от 2026-09-16 23-00-36" 
src="https://github.com/user-attachments/assets/9a6e6203-5994-498b-9c2c-34c94644ffb5";
 />
   
   ### TESTING INSTRUCTIONS
   
   ```bash
   pytest tests/unit_tests/utils/excel_tests.py -q
   ```
   
   Manual:
   
   1. Dataset with `TIMESTAMP WITH TIME ZONE` (or virtual dataset
      `excel_qa_virtual_dataset.sql` in the parent folder).
   2. Table chart, raw records, column `event_ts_msk` visible.
   3. Download → Excel.
   4. Confirm the cell is an Excel datetime equal to Explore, not a string with 
an
      offset, and not shifted by `tz_convert(None)`.
   5. Repeat with Pivot Table v2 using a temporal row or column.
   
   Timezone other than UTC (e.g. Europe/Moscow): the clock on screen must match
   the Excel cell. Do not expect SQL `timestamp AT TIME ZONE` to show local
   midnight if Postgres stored UTC.
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] 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