XLS Download from PHP Class!
Following on from my last post on creating a proper XLS spreadsheet from PHP I have just written a small class which will do all the hard work for you if necessary.
It will handle rows and columns automatically aswell as being able to be passed an array and then generating a spreadsheet download for you.
Sample usage is as follows:
//Require the file require_once (SHARED_CLASSES_DIR . 'xls.class.php'); //Instantiate the class. $xls = new xls(); //Just build an example array out of test data $array = array( array(1,2,3,4,'five') , array('five','test' ,4,3, 0) ); //Triggers the download using the passed array $xls->download_from_array($array);
Note that when instantiating the class you can pass a string as an argument and it will set the name of the XLS download. No need to add .xls to the end because it will do that for you.