scanny/python-pptx — pull request #65 by adurdin (2013-12-09 09:43:29+00:00)
Title: Embed charts from xlsx files

This code adds the ability to embed a chart from an Excel spreadsheet into a presentation. The first chart in the spreadsheet is used, and the spreadsheet itself is also embedded so that that chart remains fully editable.

Example usage:

```
# Create a presentation with one slide
from pptx import Presentation
from pptx.util import Inches
prs = Presentation()
slide = prs.slides.add_slide(prs.slidelayouts[5])

# Add the chart to a slide (can use a file-like object or a filename)
slide.shapes.add_chart_from_spreadsheet("chart.xlsx",
Inches(0.5), Inches(1.75), Inches(9), Inches(5))

# Save the presentation
prs.save("chart.pptx")
```

Multiple charts may be added to a presentation, but each must be embedded independently. This is due to limitations (AFAICT imposed by Powerpoint and not by ISO/IEC 29500) that prevent multiple chart shapes referencing a single embedded chart, or multiple embedded charts referencing a single embedded spreadsheet. The latter is possible with linked spreadsheets, but is not implemented in this code.