Skip to content
Advertisement

After reading and writing an excel file using phpSpreadSheet, the graph disappears

I’m trying to fill an excel file with data coming from a mysql server and using phpSpreadSheet. Then, I need to create a graph so users can see the graph already made. I can fill the excel file no problem, but the graph doesn’t show up. So I decided to simplify the problem by adding the headers and the graph in an empty file, read this file, write the data into this file, and export it for users (with a download button). But even in this case, the graph is absent after opening it. I then used a very simple code and it still doesn’t show up. So I think the problem that I can’t resolve is the same in all cases. What am I doing wrong so the graph disappears? This is the code I first used when I created the file and tried to create the graph :

JavaScript

This is what I get (note that if I make the graph manually using columns E and F, it works fine):

enter image description here

And that’s the simple code that I used with an excel file that already contain the graph

JavaScript

Below is what I have. Top is the input file (data.xls) and bottom is the output (write.xls) enter image description here

Thank you for your help

Laurent

Advertisement

Answer

I fixed my problem thanks to Kramar: PHPSpreadsheet generates invalid file with charts

I simply changed the displayBlanksAs to ‘gap’ instead of 0!

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement