Exporting Data to Files with PHP

with David Powers
please wait ...
Exporting Data to Files with PHP
Video duration: 0s 3h 42m Intermediate


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.

Topics include:
  • Connecting to the database with PDO or MySQL Improved
  • Outputting data into a simple text or CSV file
  • Generating a spreadsheet
  • Creating columns and headers
  • Using a class to generate XML
  • Creating a page template


- [Voiceover] Hi, I'm David Powers. Welcome to Exporting Data with PHP, a practical guide to generating different types of files from a database result. We'll begin with basic formats, plain text and CSV files. Then I'll show you how to generate a professional-looking spreadsheet in Microsoft Excel format with PHP Excel, a powerful open-source library. We'll compare the results with another library that generates OpenDocument spreadsheets.

After taking a look at exporting to rich text format with PHPRtfLite, the final part of the course shows how to generate word process documents in OpenDocument text and Microsoft Word formats. As well as text, you'll embed images in the files. There's a lot to get through, so let's get started exporting data with PHP.

please wait ...