From the course: PHP: Exporting Data to Files

Unlock the full course today

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

Downloading the data as a .xlsx file

Downloading the data as a .xlsx file - PHP Tutorial

From the course: PHP: Exporting Data to Files

Start my 1-month free trial

Downloading the data as a .xlsx file

We've written a lot of code, so it's a good idea to comment the script before we forget what it's all about. We began by setting the metadata for the spreadsheet. So let's add a new line in here, and then on line 8, set metadata. Next, we set the default settings. That began on line 13. And then we've got a reference to the active spreadsheet within an xl workbook. And if we scroll down the next thing was to set the Print options. These included the Page Orientation and headers and footers. The next step was to populate the spreadsheet with data. And we began with setting the column headings. And then the do while loop that populated individual cells. And then we formatted individual columns. If we just tidy that up there. And the last thing that we did was to give the spreadsheet a title. So, finally, we're ready to generate an excel file and download it. First thing that we need to do before downloading is to tell the browser what sort of file to expect by sending some http headers.…

Contents