So the challenge for me lately has been to be able to push data directly to an Excel spreadsheet without changing the contents of a fairly complicated dashboard sheet.
We where using a particular package on the PHP side of things and we we’re trying to accomplish this there, however it would take in the whole file and then interpret it the best it could and then output the file. This would always mess up our dashboard page so it just wasn’t going to work.
After fixing other problems, I came back to the problem and I was able to find a package on the JS side of things that would solve the problem. A package I found on npm.org, called xlsx-populate was able to load the file and pump data into it without editing or damaging the dashboard sheet. This was an awesome find!
After doing some testing I could see that it was going to work! That was an amazing moment, I was super stoked!
However after doing a bit more research I realized that I didn’t have teh file in a .xlsx format on the server side of things, rather it was a .csv file. Well xlsx-populate didn’t work with .csv, or at least I couldnt’ figure it out immediately.
So off I went to find an option to convert .csv files to .xlsx on teh PHP side of things. I went to the PHPSpreadsheet package that we already were working with. So with a little looking around I was able to get it set up, but I couldn’t get to the documentation that I needed in order to do this conversion.
So i found something on google about how to set values to an .xlsx file from an Array, which is what I was having a hard time looking for. However the documentation page for phpspreadsheet was down and it kept giving me a wierd 404 page. Wow how inconvenient!
However I wasn’t going to take no for an answer, I was able to view the cached site that google keeps and i was able to find the information I needed that way to then be able to set a range of values from an array! Wow that is a crazy way to find the solution!
I thought that was an interesting struggle and a way to find the answer. Good thing Google’s huge enough to cache the worlds websites.