read_excel_charts
read_excel_charts(path)Read every chart in an Excel workbook.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| path | str, os.PathLike or binary file object | An .xlsx or .xlsm workbook, or an open binary stream of one, such as an uploaded file. |
required |
Returns
| Name | Type | Description |
|---|---|---|
| list of ExcelChart | One per chart maidr can read, sheet by sheet in tab order and, within a sheet, top to bottom and left to right. Pass one to :func:maidr.show, :func:maidr.render or :func:maidr.save_html. |
Raises
| Name | Type | Description |
|---|---|---|
NotAWorkbookError |
If the file is not an .xlsx workbook: an older .xls file, a CSV file, or a Strict Open XML workbook. A ValueError. |
Notes
Every chart type Excel draws is read. Column and bar charts (clustered, stacked and 100% stacked), line charts (plain, stacked and 100% stacked), pie, doughnut, pie-of-pie and bar-of-pie charts, scatter and bubble charts, area charts, radar charts, stock charts, surface charts, and combinations of them, including a second value axis; and the chart types Excel 2016 added: histogram, Pareto, box and whisker, waterfall, funnel, treemap, sunburst and map. 3-D variants read as their flat counterparts.
Where matplotlib has a call for a chart it is drawn with it, and read as that call is; where it has none – a radar, a bubble chart’s sizes, a stock chart’s candles, a waterfall, a funnel, a treemap, a sunburst and a map – maidr draws the marks itself and reads the chart’s own values. A histogram’s bins and a box’s quartiles are worked out as Excel works them out, from the values the chart keeps. A map is read as the list of its regions and drawn as bars, since the shapes of its regions are not read.
An axis with no title is named after the header cell above its category range, which the reader hears and the drawing leaves out, as Excel does. A category with no label reads (blank), and a blank value is a gap, never a zero. What a chart cannot show, such as the negative values of a pie, and any chart part maidr cannot read, is left out with a UserWarning naming the chart and its sheet.
Examples
>>> import maidr
>>> for chart in maidr.read_excel_charts("sales.xlsx"):
... maidr.save_html(chart, f"{chart.name}.html")