Forum


Replies: 11   Views: 3231
Change data chart from xlsx
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 Red Nacional de Refugios  · 20-11-2017 - 17:50

https://drive.google.com/open?id=1y5H8rZOHw-vGM1QAnB0MTIA53NQdqjqD

 i haver it xlsx,  

can't   i change the data from chart?

can  you help me pls?

 my code is


 $gr1=storage_path('reporteword2017/gr.xlsx');

 $data = array(
                'legend' => array('Mujeres', 'Hijas', 'Hijos','Total'),
                'data' => array(
                    array(
                        'name' => 'Enero',
                        'values' => array(10, 20, 5,10, 20, 5,10, 20, 5,10, 20, 5),
                    ),
                    array(
                        'name' => 'Febrero',
                        'values' => array(10, 20, 5,10, 20, 5,10, 20, 5,10, 20, 5),
                    ),

                    array(
                        'name' => 'Marzo',
                        'values' => array(10, 20, 5,10, 20, 5,10, 20, 5,10, 20, 5),
                    ),
                    array(
                        'name' => 'Abril',
                        'values' => array(10, 20, 5,10, 20, 5,10, 20, 5,10, 20, 5),
                    ),
                    array(
                        'name' => 'Mayo',
                        'values' => array(10, 20, 5,10, 20, 5,10, 20, 5,10, 20, 5),
                    ),
                    array(
                        'name' => 'Junio',
                        'values' => array(10, 20, 5,10, 20, 5,10, 20, 5,10, 20, 5),
                    ),
                    array(
                        'name' => 'Julio',
                        'values' => array(10, 20, 5,10, 20, 5,10, 20, 5,10, 20, 5),
                    ),
                    array(
                        'name' => 'Agosto',
                        'values' => array(10, 20, 5,10, 20, 5,10, 20, 5,10, 20, 5),
                    ),
                    array(
                        'name' => 'Septiembre',
                        'values' => array(10, 20, 5,10, 20, 5,10, 20, 5,10, 20, 5),
                    ),
                    array(
                        'name' => 'Octubre',
                        'values' => array(10, 20, 5,10, 20, 5,10, 20, 5,10, 20, 5),
                    ),
                    array(
                        'name' => 'Noviembre',
                        'values' => array(10, 20, 5,10, 20, 5,10, 20, 5,10, 20, 5),
                    ),
                    array(
                        'name' => 'Diciembre',
                        'values' => array(10, 20, 5,10, 20, 5,10, 20, 5,10, 20, 5),
                    )
                )
            );
            
            $paramsChart = array(
                'externalXLSX' => array(
                    'src' => $gr1,
                ),
                'sizeX' => 15,
                'sizeY' => 7,
                'chartAlign' => 'center',
                'data' => $data
            );
    
//            return $this->docx->getTemplateVariables();
            $chart = new WordFragment($this->docx, 'document');
            $chart->addChart($paramsChart);
            $this->docx->replaceVariableByWordFragment(array('graficas' => $chart));