…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 store that as row, and then use the custom function that…

Resume Transcript Auto-Scroll

Author

Released

4/11/2014

Providing a file from a database in exactly the same format that's requested by the user is an extremely valuable technique. In this course, David Powers shows you how to export data from a database with PHP in a variety of formats, including rich text, CSV, Excel, Word, OpenOffice spreadsheets and documents, and even XML. He introduces tools like PHPExcel and PHPRtfLite that make the job of formatting the data (fonts, headers, columns, and all) easier to manage, and also shows how to embed nontext data like images in your exports.