PHP Classes

PHP Excel XML Export: Generate Excel spreadsheets in XML format

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 416 All time: 6,440 This week: 61Up
Version License PHP version Categories
excel-xml 1GNU General Publi...5PHP 5, Files and Folders
Description 

Author

This class can generate Excel spreadsheets in XML format.

It takes arrays with the definition of the titles and data cells and generates a XML document in Excel spreadsheet format with the specified data.

The class can detect the type of data for each cell based on the format of the value. Currently the class can detect cell data of types string, number, date, timestamp or time.

The generate Excel document can be served for download or saved to a given file.

Picture of Gianluca Zanferrari
  Performance   Level  
Name: Gianluca Zanferrari <contact>
Classes: 19 packages by
Country: The Netherlands The Netherlands
Innovation award
Innovation award
Nominee: 5x

Example

<?php
require_once('class.excel_xml.php');

$xls = new excel_xml; // initiate the class

$xls->set_titles(array('title one','title two','title three')); // optional: sets the titles of the spreadsheet columns

// adding 6 rows to the spreadsheet

$xls->add_row(array('text',-22.2,'bla bla')); // first row

$xls->add_row(array('1500.3',14.5,'bingo!')); // second row

$xls->add_row(array('2014-11-01',14.5,'a date in cell A4!!')); // third row

$xls->add_row(array('Timestamp in cell C5',14.5,'2014-11-01 12:00:10','extra data, a longer text')); // fourth row

$xls->add_row(array()); // fifth (empty) row

$xls->add_row(array('Time in cell C7',14.5,'12:00:10'));// sixth row

// writes output to file.xml (check please write permissions)
//$xls->output('file'); // comment it out to enable writing

// send the data to the browser
$xls->output();


  Files folder image Files (2)  
File Role Description
Plain text file class.excel_xml.php Class class itself
Accessible without login Plain text file example.excel_xml.php Example example

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:416
This week:0
All time:6,440
This week:61Up