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 - PHP Tutorial
From the course: PHP: Exporting Data to Files
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Introducing PHPExcel3m 31s
-
Setting properties and defaults in PHPExcel6m 58s
-
Setting the spreadsheet's print options5m 59s
-
Populating an Excel spreadsheet with data7m 46s
-
Formatting columns in PHPExcel5m 47s
-
Downloading the data as a .xlsx file5m 18s
-
Creating a spreadsheet in the OpenDocument format3m 4s
-
Creating columns and headers in Fusonic SpreadsheetExport6m 26s
-
Adding the data and downloading as a .ods file6m 52s
-
-
-
-
-
-