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.
Populating an Excel spreadsheet with data - PHP Tutorial
From the course: PHP: Exporting Data to Files
Populating an Excel spreadsheet with data
Before adding the data, let's take another quick look at the finished spreadsheet. PHP xl needs to know which cell to put each item into. Across the top, each column is referred to by a letter beginning with A. Our database results has seven columns. So the final one is G. Each row has a number beginning at one. So the column headings go in cells A1 to G1. The final column G, contains a lot of text. So we'll need to make that wider than the other columns, but we can set the other columns to autosize. So they'll expand or contract depending on the size of the data that's in them. Each cell needs to be populated individually using the column letter and row number as a reference. So now we know what we've got to do, let's get back to the editing program and get to work. The code needs to go at the bottom of the tri block after the code that we've already created. I'm going to add a few lines after line 28, and then the first thing is to get the first row from the database result. So…
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
-
-
-
-
-
-