Create Interactive Excel Charts with Python Using xlwings Lite and pyecharts
To make interactive charts from Excel data, read the Excel table into pandas and draw it with the pyecharts library, all inside Excel through the free xlwings Lite add-in. The result is an HTML file with hover tooltips, zoom sliders and a toolbox, which opens in any browser. Several charts can share one tabbed dashboard file.
Table of contents
What an interactive chart adds
An interactive chart reacts to the person reading it. Hover over a bar to see the exact value, drag a slider to zoom into three months, switch a bar chart to a line chart, or save it as an image. A regular Excel chart shows one fixed view, and the reader needs Excel to open it.
The charts in this tutorial are HTML files. They open in any browser, so you can send one to a manager or a client who does not have your workbook. They also come with small animations when they load, which is a nice touch in a meeting.
The starting point is a normal Excel table with product revenue and the default column chart Excel draws for it. Eight products with long names, rotated labels and a big legend. By the end of this post the same data is a sorted, labeled, hoverable chart in a five-tab dashboard.

Requirements and setup
You need Excel for Microsoft 365 or Excel 2021 or newer, the free xlwings Lite add-in, and two Python packages, pandas and pyecharts. You do not install Python itself. xlwings Lite brings its own Python, runs it locally on your computer and saves the code inside the workbook.
-
Install xlwings Lite. On the Home tab click Add-ins, then More Add-ins. Search for xlwings Lite, click Add and then Continue. An editor opens in a pane on the right. To check it works, pick one of the built-in examples and run it: the seaborn example adds a new sheet with a table and a chart.
-
List the packages. Open the requirements.txt tab and add
pandasandpyecharts, one per line. You can delete the lines for matplotlib and seaborn if you do not use them. -
Restart the add-in. Every change in requirements.txt needs a restart. Click the restart link xlwings Lite shows, and the Output panel lists the packages it installed.

If xlwings Lite is new to you, my introduction to xlwings Lite explains the pane, scripts and custom functions in more detail.
Your first interactive chart
Read the Excel table into a pandas DataFrame, give two of its columns to a pyecharts chart, and render the chart to an HTML file. A decorator turns the Python function into a button in the xlwings Lite pane, so you rebuild the chart with one click whenever the data changes.
This is the shortest version that works. It reads the table tblProducts on the sheet Bar:
import pandas as pd
import xlwings as xw
from pyecharts.charts import Bar
from xlwings import script
OUT = "/data"
@script(name="Bar - Minimal")
def bar_minimal(book: xw.Book):
table = book.sheets["Bar"].tables["tblProducts"]
df = table.range.options(pd.DataFrame, index=False).value
chart = Bar()
chart.add_xaxis(df["Product"].tolist())
chart.add_yaxis("Revenue", df["Revenue"].tolist())
chart.render(f"{OUT}/bar_minimal.html")
print("Done: bar_minimal.html")
Step by step:
bookis the open workbook. xlwings Lite passes it in, and through it you reach any sheet and any Excel table by name..options(pd.DataFrame, index=False).valueconverts the table into a DataFrame.index=Falsestops pandas from treating the first column as an index.@script(name="Bar - Minimal")makes the function a script. The name is the label you pick in the pane’s run button.Bar(),add_xaxisandadd_yaxisbuild the chart, andrenderwrites it as an HTML file.
Run the script. The Output panel prints the message, and the file appears in the xlwings Lite menu under Files, Import/Export. The /data folder is special: whatever your code writes there shows up in that list. Click the download icon and open the file in your browser.

The first chart is plain, with default colors and some product names skipped on the axis. It is already interactive, though: hover over a bar and a tooltip shows the exact revenue.

Save to a local folder
Connect a real folder in the xlwings Lite Files menu under Local Folders, then use that folder’s path in your code instead of /data. Every run then writes the HTML file straight into the folder, ready to attach to an email.
-
Create the folder. For example a folder called charts next to your workbook.
-
Add it in xlwings Lite. Open the menu, go to Files, switch to the Local Folders tab, click Add Folder and select the charts folder.
-
Change the path. The folder appears in Python under its name, so set
OUT = "/charts"and run the script again.
I did this in Excel on Windows in the video. Files in /data survive a restart of the add-in, but the Files panel itself warns that they are deleted when the Office cache is cleared, so a local folder is the safer home for anything you want to keep.
Polish the chart
Every part of a pyecharts chart takes options: size, colors, labels, titles, tooltips and margins. The polished bar chart sorts the products, turns the bars horizontal so long names fit, adds a title, formats the labels as money and uses one consistent color.

The core of that version:
df = df.sort_values("Revenue")
chart = (
Bar(init_opts=opts.InitOpts(width="100%", height="620px", bg_color="#FFFFFF"))
.add_xaxis(df["Product"].tolist())
.add_yaxis(
"Revenue", df["Revenue"].tolist(), bar_width="58%",
itemstyle_opts=opts.ItemStyleOpts(color="#1E7FA8", border_radius=5),
label_opts=opts.LabelOpts(
position="right",
formatter=JsCode(
"function (p) { return '$' + Math.round(p.value).toLocaleString(); }")),
)
.reversal_axis() # columns become horizontal bars
.set_global_opts(
title_opts=opts.TitleOpts(title="Revenue by Product", subtitle="FY26, USD"),
tooltip_opts=opts.TooltipOpts(trigger="axis", axis_pointer_type="shadow"),
legend_opts=opts.LegendOpts(is_show=False),
)
)
# room on the left for long product names, on the right for the labels
chart.options["grid"] = {"left": "20%", "right": "10%", "top": "18%"}
It needs two more imports: from pyecharts import options as opts and from pyecharts.commons.utils import JsCode. A few things I learned building it:
- Thousands separators in labels need a small JavaScript formatter, the
JsCodeline above. The plain string formatters cannot do it. reversal_axis()is how you get horizontal bars. There is no separate chart type for them.- pyecharts has no option for the plot margins, so the code sets
chart.options["grid"]directly. - Keep the colors in a few constants at the top of the script. Change them once and every chart follows.
You do not need to memorize these options. Start from a working chart, change one thing at a time, and let AI help when you get stuck, which I come back to at the end.
Line, combo, waterfall and pie
The workbook has five: bar, line, combo, waterfall and pie. Each one uses the same three moves, read the table, build the chart, render. Only the chart object and its options change. pyecharts has many more types, from maps to Sankey diagrams.
Line chart with a zoom slider
Twenty-four months of revenue as a smooth line with a soft fill. A cross-shaped pointer reads the month and the value wherever you hover, and a slider under the chart zooms into any stretch. You add both with tooltip_opts and datazoom_opts.

Combo chart with a second axis
Revenue and cost as bars, margin percentage as a line on its own axis. extend_axis adds the second y-axis, yaxis_index=1 pins the line to it, and bar.overlap(line) draws both in one chart. The toolbox in the corner saves the chart as an image, shows the data, zooms and switches between bar and line.

Waterfall chart from budget to actual
pyecharts has no waterfall chart type. The trick is two stacked bar series: an invisible one that lifts each block to the right height, and a visible one for the change itself. Budget and Actual are totals and sit on the floor. This loop works out both series from a table with Step and Amount columns:
base, blocks, running = [], [], 0.0
for step, amount in zip(df["Step"], df["Amount"]):
if step in ("Budget", "Actual"):
base.append(0.0)
blocks.append(amount)
running = amount
else:
base.append(running if amount > 0 else running + amount)
blocks.append(abs(amount))
running += amount
chart = Bar()
chart.add_xaxis(df["Step"].tolist())
chart.add_yaxis("", base, stack="bridge",
itemstyle_opts=opts.ItemStyleOpts(color="rgba(0,0,0,0)"),
label_opts=opts.LabelOpts(is_show=False))
chart.add_yaxis("Change", blocks, stack="bridge")
The polished version colors increases blue and decreases amber by passing each bar as a small dictionary with its own style and label.

If you prefer Plotly, which has a real waterfall type, my Plotly waterfall chart tutorial covers that route.
Pie or donut chart
A pie chart wants name and value pairs, so the code zips the Region and Revenue columns together. Two radii, such as radius=["45%", "70%"], cut out the middle and make it a donut, and the label shows each region’s share. Keep pies for a handful of categories.
Combine the charts in a dashboard
Add each finished chart to a pyecharts Tab object and render the Tab instead of the single charts. The result is one HTML file with a tab per chart. Every chart keeps its own hover effects, sliders and toolbox, so the file works as a small dashboard you can send to anyone.
from pyecharts.charts import Tab
tab = Tab(page_title="FY26 Dashboard")
tab.add(bar_chart, "Revenue by Product")
tab.add(line_chart, "Monthly Revenue")
tab.add(combo_chart, "Revenue, Cost & Margin")
tab.add(waterfall_chart, "Budget to Actual")
tab.add(pie_chart, "Revenue by Region")
tab.render(f"{OUT}/dashboard.html")

Tip: in the workbook, the dashboard script repeats the code of the five polished charts instead of calling the other scripts. xlwings Lite turns every @script function into a coroutine, so calling one script from another builds an object nobody runs, and the chart silently never renders. Put shared chart code in a normal helper function without the decorator if you want to reuse it.
For a dashboard with filters, KPI cards and a data table rather than chart tabs, see my post on turning Excel data into an interactive dashboard with Python and AI.
Download the workbook
The workbook from the video has one sheet per chart type, each with a small Excel table and the plain Excel chart, plus a Start Here sheet. All eleven scripts, a minimal and a polished version for each chart plus the dashboard, are already stored in the file and appear in the xlwings Lite pane when you open it.
Interactive chart gallery workbook
Five sample tables with their default Excel charts and the Python code that rebuilds them as interactive pyecharts charts and one tabbed dashboard.
pyecharts, Plotly or Excel charts
Use Excel charts when the chart has to live in the workbook and be edited by others. Use pyecharts or Plotly when you want hover, zoom and a file you can share with anyone. Both Python libraries write HTML files from xlwings Lite. Neither can be inserted into the sheet as a live chart.
| Excel chart | pyecharts | Plotly | |
|---|---|---|---|
| Hover tooltips and zoom | No | Yes | Yes |
| Lives inside the sheet | Yes | No, HTML file | No, HTML file |
| Reader needs Excel | Yes | No, any browser | No, any browser |
| Built-in toolbox and chart type switch | No | Yes | Toolbar, no type switch |
| Tabbed multi-chart page | No | Yes, with Tab | Needs extra HTML |
| Opens offline | Yes | Not by default | Yes, when the library is embedded |
If you want a picture of a Python chart inside the sheet itself, xlwings Lite can insert matplotlib and seaborn figures as images. My post on inserting Python charts into Excel shows that approach. For more Plotly, see my Plotly Express quick fixes.
Troubleshooting
A blank page usually means the browser could not load the ECharts library, because pyecharts links it from the internet instead of putting it in the file. A chart that does not change means the script was not run again after the data changed. The table below covers the rest.
| Problem | Cause | Fix |
|---|---|---|
| The HTML file opens as an empty white page | The file loads echarts.min.js from assets.pyecharts.org. No internet, or a firewall blocks that address | Open it online. For offline use, host the ECharts file yourself and point pyecharts’ CurrentConfig.ONLINE_HOST at it |
ModuleNotFoundError: No module named 'pyecharts' |
The package is not in requirements.txt, or the add-in was not restarted | Add pyecharts and click restart |
| The chart shows old numbers | The HTML file is a snapshot of the table at the moment the script ran | Run the script again and download the new file |
| Toolbox tooltips appear in Chinese | pyecharts defaults the toolbox labels to Chinese | Set every title in ToolboxOpts, as the combo chart in the workbook does |
| Dates show as numbers like 45658 | Excel sends dates to Python as serial numbers | Read the table with parse_dates=["Date"] in .options() |
| A script that calls another script renders nothing | Scripts are coroutines in xlwings Lite | Copy the code or move it into a plain helper function |
| Generated files are gone | Files in /data are deleted when the Office cache is cleared |
Download them, or write to a connected local folder |
More charts with Wingman
The pyecharts gallery shows hundreds of examples with their code, from pictorial bars to maps, Sankey diagrams and liquid fill gauges. Pick one, copy its link, and ask Wingman, the AI assistant built into xlwings Lite, to rebuild it with the table in your workbook.
Wingman has to be connected to a large language model such as ChatGPT or Claude first. Then paste the gallery link, name your table and columns, and run the script it writes. Check the chart against your data before you send it on, since AI can map the wrong column with total confidence.
Some ideas from older tutorials of mine that use pyecharts: a liquid fill chart from Excel data and an Excel dashboard built with pyecharts in a regular Python setup. If you want numbers that refresh by themselves rather than charts, my post on custom Excel formulas that update automatically uses the same add-in.
If pandas, DataFrames and scripts are new to you, my course teaches the Python you need for Excel automation in 52 short lessons, explained from an Excel user’s point of view, then builds one automation project step by step with AI as a helper.
