PHP: Exporting Data to Files
3h 43mIntermediate2014-04-11
Authors

David Powers
Developing websites since 1994
Course details
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.
Skills covered
PHPProgramming LanguagesOpen SourceSoftware DevelopmentDeep Dive (X:Y)
Concepts
0. Introduction
- 01 - Welcome
- 02 - What you should know before watching this course
- 03 - Using the exercise files
1. Setting Up
- 04 - Loading the test data into a database
- 05 - Querying the database with MySQL Improved
- 06 - Connecting to different databases with PHP Data Objects (PDO)
- 07 - Querying the database with PDO
- 08 - Displaying the data in a webpage
- 09 - Autoloading classes
2. Basic File Formats
- 10 - Outputting the database result to a text file
- 11 - Outputting the result as a CSV file
- 12 - Introducing the Base class for file downloads
- 13 - Using the Text class for greater control over output
- 14 - Controlling CSV options with the Csv class
- 15 - Saving the data to a local file
3. Generating a Spreadsheet
- 16 - Introducing PHPExcel
- 17 - Setting properties and defaults in PHPExcel
- 18 - Setting the spreadsheet's print options
- 19 - Populating an Excel spreadsheet with data
- 20 - Formatting columns in PHPExcel
- 21 - Downloading the data as a .xlsx file
- 22 - Creating a spreadsheet in the OpenDocument format
- 23 - Creating columns and headers in Fusonic SpreadsheetExport
- 24 - Adding the data and downloading as a .ods file
4. Exporting as Rich Text Format
- 25 - Installing PHPRtfLite
- 26 - Defining the page margins and the footer
- 27 - Setting heading and paragraph styles
- 28 - Adding the data and outputting a .rtf file
5. Exporting to Word Processor Formats
- 29 - Understanding the basic process
- 30 - Merging XML documents with XSLT
- 31 - Preparing a directory to generate the output
- 32 - Generating XML from a database result
6. Generating an OpenDocument Text File
- 33 - Creating a .odt file to use as a template
- 34 - Inspecting the structure of an OpenDocument text file
- 35 - Extracting the main content file from a .odt document
- 36 - Converting the main content file to XSLT
- 37 - Outputting the database result as a .odt file
7. Generating a Microsoft Word File
- 38 - Creating a .docx file to use as a template
- 39 - Extracting the main content file from a Word document
- 40 - Formatting the main content file
- 41 - Converting the main content file to XSLT
- 42 - Outputting the database result as a .docx file
- 43 - Offering a choice of download formats
Conclusion
- 44 - Goodbye