From the course: PHP: Exporting Data to Files

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Adding the data and downloading as a .ods file

Adding the data and downloading as a .ods file - PHP Tutorial

From the course: PHP: Exporting Data to Files

Start my 1-month free trial

Adding the data and downloading as a .ods file

Once you've defined the columns, you can add the data. Fusonic spreadsheet export adds a whole row at a time. The addRow method simply takes an array of values and populates the columns in the same order as they were defined. So let's populate the data of our Open Document spreadsheet. The code needs to go at the end of the triblock, so i'll add a couple of extra lines after line 29, and then get typing. We need a wild loop to go through the database results so, while then $row = then we'll use our custom function getRow. So it works with both mySQLi and pdo, and we parse it, result which is our database result. And then inside there we just need add each row to our spreadsheet. So it's the sheet object, and the add row method. And we parse it, the current row. That's really all you need to do to populate the data of an OpenDocument spreadsheet using Fusonic spreadsheet export. But there are a couple of problems. The first one is that OpenDocument format stores data as XML. So, if…

Contents