The class usage is documented within the zip. It also follows; <?php /* A quick script to demo the use of the export-xls.class.php script. */ //include the export-xls.class.php file require('export-xls.class.php'); $filename = 'test.xls'; // The file name you want any resulting file to be called. //create an instance of the class $xls = new ExportXLS($filename); //lets set some headers for top of the spreadsheet $header = "Test Spreadsheet"; // single first col text $xls->addHeader($header); //add blank line $header = null; $xls->addHeader($header); //add 2nd header the import cannot be resolved as an array of 3 columns $header[] = "Name"; $header[] = "Age"; $header[] = "Height"; $xls->addHeader($header); /* Lets add some sample data Of course this can be from a SQL query or anyother data source */ //first line $row[] = "Jack"; $row[] = "24"; $row[] = "6ft 5"; $xls->addRow($row); //second line $row = array(); $row[] = "Jim"; $row[] = "22"; $row[] = "5ft 5"; $xls->addRow($row); //add a multi dimension array $row = array(); $row[] = array(0 =>'Jess', 1=>'54', 2=>'4ft'); $row[] = array(0 =>'Luke', 1=>'6', 2=>'2ft'); $xls->addRow($row); /* You can return the xls as a variable to use with; $sheet = $xls->returnSheet(); OR You can send the sheet directly to the browser as a file */ $xls->sendFile(); ?>
Hi Ocptime Thanks for the comment. At the moment it is not possible to format the cells in anyway. However i may look into trying to get it to do that in a future release. So watch this space ;) Reply Delete
Leenix / you have committed small genius with this class - after fiddling around with phpexcel (phpexcel.codeplex.com) and its completely heavyweight (and possibly broken?) approach it was sheer joy to find your minimalist solution to exporting Excel XLS data. You can add a high-five to the collection! :) Reply Delete
I have tried to use Japanese character at the xls file, but it only shows wired character. the import cannot be resolved What charset do I have to use? Reply Delete
Hi, First of all, great script, very easy to use. But i'm tring to export non-Latin characters which are stored on database as UTF-8, but when exported, the characters are shown as ??????. I tried iconv but it doesn't seem to produce the right result. Any help would be appreciated. Thank you! Reply Delete
Everisk: Thank you. Yes ive seen this problem reported before. I'd like to find some time to dig into this deeper, but as of yet ive not found the time. Please report back if you find a solution. Reply Delete
Hi Leenix, I love your class ;) very easy, I had my task done very rapidly this morning tnx to you ;) Personally, I needed to save my file directly to filesystem without echoing it, so I added a simple "saveToFile" function (file_put_contents($filename, $this->returnSheet());) Tnx again!! Muryan Reply Delete
► 2012 (3) ► July (1) ► April (1) ► January (1) ► 2011 (2) ► June (1) ► May (1) ► 2010 (11) ► December (1) ► October (2) ► August (1) ► July (1) ► the import cannot be resolved April (3) ► March (1) ► February (1) ► January (1) ▼ 2009 (14) ► December (1) ► October (2) ► September (2) ► July (3) ► May (1) ▼ April (1) Lightweight PHP Class to export to Excel XLS Forma... ► March (1) ► February (2) ► January (1)
No comments:
Post a Comment