Using PHP with PEAR to export an Excel File
Some people like to tell us “Use COM object to create an Excel File”.
It is a general answer, if you are using Windows OSs and installed Microsoft Office with Excel Application.
So, how do we can create an Excel File without using any Microsoft / Windows components ?
PEAR is one of best way for us to complete this mission.
PEAR Official Website
PEAR @ Wiki
First, you should install PEAR.
Open the Terminal and type
sudo apt-get install php-pear
To install PEAR and its relative package.
sudo gedit /etc/php5/apache2/php.ini
find include_path after UNIX
uncomment include_path and edit the string of included path to .:/usr/share/php:/usr/share/php/PEAR
(Note: The included path base on which path you would like to include, you can add more included path separated by a colon)
sudo service apache2 restart
To restart Apache2
Create a PHP in your web directory and type <?php phpinfo(); ?> to get information of Apache2.
Make sure the include_path is included .:/usr/share/php:/usr/share/php/PEAR
Visit http://pear.php.net/package/Spreadsheet_Excel_Writer/download and http://pear.php.net/package/OLE/download
to download Spreadsheet_Excel_Writer and OLE package.
You can download and move them to specific locations manually.
Copy the PEAR Install Command and paste them to Terminal to install them automatically.
We suggest you use PEAR Install Command.
You should super user or root account to install them.
sudo pear install Spreadsheet_Excel_Writer-0.9.2 sudo pear install OLE-1.0.0RC1
Make sure Spreadsheet_Excel_Writer and OLE directories are included if you want to use them.
Create a simple PHP file for exporting Excel file.
Open a browser to browse the PHP file for exporting Excel file.
You can visit Spreadsheet Excel Writer APIs to get more information for exporting.