PHPExcel API for Open XML


PHPExcel is a set of classes that enable Open XML spreadsheet development, available as an open-source project on Codeplex. Using these classes, PHP programmers can easily create spreadsheets with formulas, conditional formatting, and other features. Here’s a sample of a spreadsheet created with PHPExcel:


sample spreadsheet


Classes are provided for the main elements you’ll need to create richly formatted spreadsheets: a worksheet class, data cell class, style class, and so on. These classes allow PHP developers to generate Open XML spreadsheets easily, with very few lines of code. For example, here are some typical samples of the simple syntax you’ll see in code that’s based on PHPExcel:


// write a value to a cell
$PHPExcel->getActiveSheet()->setCellValue(‘D12′,’Total’);

// set document metadata property
$PHPExcel->getProperties()->setCreator(‘John Doe’);


Maarten & JakubThe creators of PHPExcel are Maarten Balliauw and Jakub Vrana. I met Jakub at the Open XML workshop we had in Prague last month, and Maarten attended my presentation at Developer & IT Pro Days in Ghent. Maarten has written an article for the April 2007 issue of php architect magazine that provides some information about how to use PHPExcel and an introduction to the SpreadsheetML file format.


PHP is an extremely popular language for dynamic web pages, and PHPExcel allows those types of applications to generate Open XML spreadsheets without any need for other APIs or server software. As Maarten explains in his php architect article, the use of PHPExcel eliminates any need for special software on the server, and runs just as well (some might say better, but we’re working on that :-)) on a Linux server as on a Windows server.


Nice job, Maarten and Jakub! Anybody want to help them extend this cool tool into word-processing documents next?