Provides access to external chart data in a linked or embedded Excel workbook.
| 55 | |
| 56 | |
| 57 | class ChartWorkbook(object): |
| 58 | """Provides access to external chart data in a linked or embedded Excel workbook.""" |
| 59 | |
| 60 | def __init__(self, chartSpace, chart_part): |
| 61 | super(ChartWorkbook, self).__init__() |
| 62 | self._chartSpace = chartSpace |
| 63 | self._chart_part = chart_part |
| 64 | |
| 65 | def update_from_xlsx_blob(self, xlsx_blob): |
| 66 | """ |
| 67 | Replace the Excel spreadsheet in the related |EmbeddedXlsxPart| with |
| 68 | the Excel binary in *xlsx_blob*, adding a new |EmbeddedXlsxPart| if |
| 69 | there isn't one. |
| 70 | """ |
| 71 | xlsx_part = self.xlsx_part |
| 72 | if xlsx_part is None: |
| 73 | self.xlsx_part = EmbeddedXlsxPart.new(xlsx_blob, self._chart_part.package) |
| 74 | return |
| 75 | xlsx_part.blob = xlsx_blob |
| 76 | |
| 77 | @property |
| 78 | def xlsx_part(self): |
| 79 | """Optional |EmbeddedXlsxPart| object containing data for this chart. |
| 80 | |
| 81 | This related part has its rId at `c:chartSpace/c:externalData/@rId`. This value |
| 82 | is |None| if there is no `<c:externalData>` element. |
| 83 | """ |
| 84 | xlsx_part_rId = self._chartSpace.xlsx_part_rId |
| 85 | return None if xlsx_part_rId is None else self._chart_part.related_part(xlsx_part_rId) |
| 86 | |
| 87 | @xlsx_part.setter |
| 88 | def xlsx_part(self, xlsx_part): |
| 89 | """ |
| 90 | Set the related |EmbeddedXlsxPart| to *xlsx_part*. Assume one does |
| 91 | not already exist. |
| 92 | """ |
| 93 | rId = self._chart_part.relate_to(xlsx_part, RT.PACKAGE) |
| 94 | externalData = self._chartSpace.get_or_add_externalData() |
| 95 | externalData.rId = rId |
no outgoing calls
searching dependent graphs…