pythonopenpyxl

Read charts from .xlsx file in Python


I am using openpyxl library to read .xlsx files in Python. I need to read some information (title, series names etc) about charts embedded in worksheets. Documentation mentions only creating new charts, and reading existing charts is nowhere mentioned.

#!/usr/bin/env python

from openpyxl import load_workbook
wb = load_workbook("charts.xlsx")
for sheet in wb:
    # wb.???

Solution

  • Unfortunately the current version of OpenPyXL does not allow to load charts from Excel files. If you load a Workbook and immediately save it to the same filename you will effectively remove the charts from it.