Forum


Replies: 7   Views: 1794
Importchartstyle from example doesn't work?
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 23-01-2020 - 20:07

Hello,

The importChartStyle method imports colors and style XML files from an external DOCX chart, but these XML files don't apply color to the chart automatically (they add them to be used, but colors and some options can only be used after being applied to the chart XML), colors can be applied using the theme option available in the addChart method. On the package, examples/Core/addChart, you can find samples about using the theme option.

We have tested the included sample (LayoutAndGeneral/importChartStyle/sample_1.php) and the output is the expected; both files (colors and style XML files are imported). This method can be used with the theme option available in the addChart method to get the needed output.

As an alternative approach, if you don't want to use the theme option, you can import a DOCX with a chart using mergeDocx or mergeDocxAt and change its values using replaceChartData (https://www.phpdocx.com/api-documentation/docxutilities/replace-chart-data-Word-document). The three XML files of the chart will be imported: chart, colors and style.

Regards.