replaceChartData

replaceChartData

ADVANCED / PREMIUM TRIAL

Replaces the data associated with a given chart (titles, categories, legends, sections and values).

Description
public replaceChartData (string $source, string $target, array $data)

This method allows to replace the chart data in an existing Word document. You may fully customize the chart via the Word interface before inserting the real data with the help of phpdocx.

The chart type to be updated must be supported by addChart. Extended charts are not supported.

Parameters

source

Path to the DOCX.

target

Path to the resulting DOCX.

data

The keys are the numbers of the charts to replace and the values are arrays of data as described in the addChart method.

Exceptions

Error while trying to open the (base) template as a zip file.

The index chart does not exist.

Code samples

Example #1

Release notes
  • phpdocx 15.5:
    • removed @ (shut-up) operator to get categories.
  • phpdocx 14.0:
    • return DOCXStructure.
  • phpdocx 13.5:
    • DOCXStructure and in-memory DOCX documents.
  • phpdocx 12.0:
    • use the default temp folder to generate XLSX files.
  • phpdocx 8.0:
    • add editable XLSX.
  • phpdocx 7.0:
    • improved to support titles, legends and categories.