PHP Classes
elePHPant
Icontem

PHP Export Data: Export data in CSV, TSV, or Excel XML formats

Recommend this page to a friend!
  Info   View files Documentation   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2017-09-05 (13 days ago) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
php-export-data 1.0Custom (specified...5PHP 5, Files and Folders
Description Author

This class can export data in CSV, TSV, or Excel XML formats.

It can take data in arrays to be added as rows of tabular data.

The class can export the data in several output formats as the data rows are added to the tabular data stream.

The class can be exported to the formats CSV, TSV, or Excel XML (aka SpreadsheeML) either to a file or directly to the browser.

Name: Ionut-Alexandru Toma <contact>
Classes: 1 package by
Country: Romania Romania

Details

php-export-data by Eli Dickinson

http://github.com/elidickinson/php-export-data

Released under the permissive MIT License: http://www.opensource.org/licenses/mit-license.php

A simple library for exporting tabular data to Excel-friendly XML, CSV, or TSV. It supports streaming exported data to a file or directly to the browser as a download so it is suitable for exporting large datasets (you won't run out of memory).

Excel XML code is based on Excel_XML by Oliver Schwarz (http://github.com/oliverschwarz/php-excel)

How to use it

<?php

// When executed in a browser, this script will prompt for download 
// of 'test.xls' which can then be opened by Excel or OpenOffice.

require 'php-export-data.class.php';

// 'browser' tells the library to stream the data directly to the browser.
// other options are 'file' or 'string'
// 'test.xls' is the filename that the browser will use when attempting to 
// save the download
$exporter = new ExportDataExcel('browser', 'test.xls');

$exporter->initialize(); // starts streaming data to web browser

// pass addRow() an array and it converts it to Excel XML format and sends 
// it to the browser
$exporter->addRow(array("This", "is", "a", "test")); 
$exporter->addRow(array(1, 2, 3, "123-456-7890"));

// doesn't care how many columns you give it
$exporter->addRow(array("foo")); 

$exporter->finalize(); // writes the footer, flushes remaining data to browser.

exit(); // all done

?>

See the test/ directory for more examples.

Some other options for creating Excel files from PHP are listed here: http://stackoverflow.com/questions/3930975/alternative-for-php-excel/3931142#3931142

  Files folder image Files  
File Role Description
Files folder imagetest (3 files)
Accessible without login Plain text file LICENSE Lic. License text
Plain text file php-export-data.class.php Class Class source
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  test  
File Role Description
  Accessible without login Plain text file test_big_excel_file.php Example Example script
  Accessible without login Plain text file test_excel_browser.php Example Example script
  Accessible without login Plain text file test_tsv_string.php Example Example script

 Version Control Unique User Downloads  
 100%
Total:0
This week:0