Skip to content

feat(chart-data): export the Spreadsheet chart to Excel with its edits - #45279

Draft
AliIbnBotir wants to merge 4 commits into
apache:masterfrom
AliIbnBotir:feat/univer-excel-export
Draft

AliIbnBotir wants to merge 4 commits into
apache:masterfrom
AliIbnBotir:feat/univer-excel-export

Conversation

@AliIbnBotir

@AliIbnBotir AliIbnBotir commented Oct 14, 2026 •

Copy link
Copy Markdown

SUMMARY

Part of SIP #45265.

Stacked on #45278 (Spreadsheet chart), which depends on #45263 and #45275. This branch contains their commits, so until they merge, please review only the last commit, feat(chart-data): export the Spreadsheet chart to Excel with its edits. Backend only.

"Export to Excel" on a Spreadsheet chart writes the sheet as the user sees it instead of the raw query result:

  • renamed headers, formulas (with cached values), cell styles, merges, column widths and frozen panes;
  • pivot mode's stacked header rows;
  • row groups as real Excel outline groups, with Subtotals and Grand Total rows.

How it works:

  • In QueryContextProcessor.get_data, an XLSX request whose form data has viz_type == "univer_sheet" goes to the new superset/utils/univer_excel.py instead of excel.df_to_excel. Every other chart takes the existing path unchanged.
  • univer_excel.py rebuilds the same sheet the browser shows (data area, pivot headers, groups, saved edits from univer_workbook) and writes it with XlsxWriter, which is already a dependency.
  • Shared formulas are moved with openpyxl's formula translator. openpyxl was already installed through pandas[excel] and is now declared directly in pyproject.toml (>=3.1.5, <4). requirements/*.txt are updated accordingly, no new package is installed.
  • It reuses the chart-data endpoint, so permissions, row limits and config apply as before. Explore sends the current form data, so unsaved edits are exported too. Dashboards, reports and alerts use the saved chart.
  • CSV and JSON exports still return the raw query result.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

05-excel-export _Export to Excel from the chart menu, and the downloaded .xlsx: renamed headers, header fill and the Average formulas are kept._

Before: the .xlsx contained the raw query result with the original column names and no formatting, formulas or groups.

TESTING INSTRUCTIONS

Automated:

  • pytest tests/unit_tests/utils/univer_excel_test.py tests/unit_tests/common/test_query_context_processor.py

Manual (needs the chart PR):

  1. Open a Spreadsheet chart in Explore, rename a header, colour the header row and add a formula row under the data.
  2. Chart menu → Download → Export to Excel. Open the file: the renamed header, fill and formulas are there, and the formulas have values.
  3. Switch to Pivot mode and export again: the stacked header rows are merged as in the browser.
  4. Turn on Group rows by dimensions and export: Excel shows outline groups (the 1/2 buttons on the left) with Subtotals rows.
  5. Export any other chart type to Excel: the output is unchanged.

ADDITIONAL INFORMATION

Arabbek and others added 4 commits October 14, 2026 17:15
flatten reset only the first level of a MultiIndex, so a pivot with
several index columns lost the others when the result was serialized.
A single-level index is reset as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Charts can tell whether they render in Explore, on a dashboard or embedded
(standalone Explore, also used for report screenshots), e.g. to allow
editing only in Explore.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A Table-category chart that shows the query result as an Excel-like sheet
using Univer's open source packages. In Explore it is a full editor whose
edits (formatting, formulas, renamed headers, extra sheets) are saved in the
chart's form data; on dashboards it is read-only with fresh data.

Query modes: aggregate, raw records and pivot (pivot and flatten
post-processing on the backend). Rows can be grouped by dimensions with
subtotals and collapsible groups.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
For the univer_sheet viz type, the XLSX chart-data export writes the sheet as
shown in the chart: renamed headers, formulas with cached values, styles,
merges, column widths, frozen panes, pivot headers and row groups as Excel
outline groups. Other charts keep the plain export.

openpyxl, already installed through pandas[excel], becomes a direct
dependency for its formula translator.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@netlify

netlify Bot commented Oct 14, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 0a62f1d
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6acf7affc18ffc66300cdc55
😎 Deploy Preview https://deploy-preview-45279--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 20.61856% with 462 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.89%. Comparing base (7f1bfab) to head (0a62f1d).
⚠️ Report is 257 commits behind head on master.

Files with missing lines Patch % Lines
superset/utils/univer_excel.py 20.52% 457 Missing ⚠️
superset/common/query_context_processor.py 16.66% 5 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (7f1bfab) and HEAD (0a62f1d). Click for more details.

HEAD has 3 uploads less than BASE
Flag BASE (7f1bfab) HEAD (0a62f1d)
python 7 5
postgres 2 1
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #45279       +/-   ##
===========================================
- Coverage   83.29%   64.89%   -18.41%     
===========================================
  Files        3039     3040        +1     
  Lines      198375   198960      +585     
  Branches    46213    46338      +125     
===========================================
- Hits       165235   129110    -36125     
- Misses      29916    66949    +37033     
+ Partials     3224     2901      -323     
Flag Coverage Δ
hive 34.90% <20.44%> (-0.08%) ⬇️
mysql 52.82% <20.61%> (-0.18%) ⬇️
postgres 52.82% <20.61%> (-0.18%) ⬇️
presto 36.65% <20.44%> (-0.09%) ⬇️
python 53.11% <20.61%> (-33.80%) ⬇️
sqlite 52.58% <20.61%> (-0.18%) ⬇️
unit ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot added the requires:rebase Requires rebasing on top of current master label Oct 15, 2026
@AliIbnBotir AliIbnBotir changed the title Feat/univer excel export feat(chart-data): export the Spreadsheet chart to Excel with its edits Oct 15, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants