5 Libraries that Help You Generate Excel Reports in PHP Application

Microsoft Excel is still the most widely used data analysis, report generation tool. If you have ever worked on any enterprise application, you must have got across the requirement of having excel export facility for various reports available in your application.

Today, we will look at various options available to PHP developers for exporting data to excel spreadsheets.


1. PHPExcel

  1. Best in class of the available options. Well maintained and active community project.
  2. Supports images,charts, formulas, multiple worksheets.
  3. Extendable: supports exporting to pdf/doc or any other format you may like. You can extend the output writer class and use any format you need.
  4. Documentation is comprehensive and easy to understand even for beginner php programmers.
  5. Can Load existing excel files and use them as base template for filling data.
  6. Also supports openXML formats used by Open office or MS office 2007 or later.

2. php-excel

  1. Lightweight library with minimal functionality required for exporting just a data only simple excel file.
  2. Good for simple data export requiring one worksheet in the excel file.
  3. MS Office 2007 or higher will give an alert saying file may not be in proper format to user before opening the file.
  4. Supports output to browser only.
  5. No support for formulas, images, charts etc.

3. Php export data

  1. Built on top of php-excel library mentioned above.
  2. Supports export to tsv/csv format besides xls format.
  3. Supports output to browser, file or string.

4. Excel Writer(XML) for PHP

  1. Supports excel formulas.
  2. Multi sheet support.
  3. Formatting support.
  4. Supports direct export from mysql tables, mysql query.
  5. Generates files in Microsoft Office 2003 XML format which opens correctly in Microsoft excel, but the extension of the file might confuse users.

5. Pear Excel Writer

  1. Supports formulas and images.
  2. Multi sheet support
  3. Formatting support.
  4. Only BIFF format i.e. .xls can be generated. No support for newer formats.

Have you used any of these or any other library for exporting data in excel format from php application? If yes, share them in comments below.