It is difficult to a render a chart in a XLS file while generating it from PHP. But its possible to link the data from a different XLS sheet and to refer it to your sheet through which you can perform calculation or even alter the charts dynamically.
To do so, please follow the steps:
Open a XLS file
Provide some datas to the file in appropriate cells
Save the file with XLS format (if you are using open office) with some name say file1.
Open the exising XLS file which has datas.
Open a new XLS file
Place the cell pointer in the cell where you want to feed the data and put equal (=) symbol denoting a reference
Now move on to the existing file and place the cursor in the cell whose value must be referred to the new sheet.
Now again come back to the new XLS, Whose formula bar will have the format
‘Path of the filename’#Sheetname.cellvalue of the referring file
click the (tick) icon or press enter.
Do the same for all the cells where you want to link with other sheets.
Step III: (To create chart)
In the new XlS file, select the data range till where you want to generate the chart.
Click the chart icon in the tool bar
Now the chart will be generated for selected data range.
Save and Close the file
Step IV :
Open the file1 XLS i.e., referring file
Alter some data values in the cells .
Save the file
Now open the newly created XLS
It will ask “ The linked document has some changes, Do you want to update it?
Now one can see the values that has been modifed in file1 gets updated in this file and chart
also gets modified according to the new set of values
We can perfom the same process by referring a URL.