0

I have written an Export script that will export data from my database as a CSV or XLS file. The data from the database needs to be manipulated first. So far I have the CSV file working and am now trying to convert this CSV string to XLS. I want to use phpExcel but get the below error. Can anyone assist?

Fatal error:  Class 'PHPExcel_Exception' not found in /var/www/leanne/api/library/PHPExcel/Exception.php on line 36

Code which is causing the error, all worked fine until I added the XLS stuff:

if($format == 'csv'){  
                //create and write to file for CSV
                if(file_exists($file_location . $filename)){
                    unlink($file_location . $filename);
                }
                $fh = fopen($file_location . $filename , 'a');
                fwrite($fh, $csv);
                fclose($fh);
            } else if($format == 'xls'){ 
                //wite to file for XLS
                include '../library/PHPExcel/IOFactory.php';

                $objReader = PHPExcel_IOFactory::createReader('CSV');
                $objReader->setDelimiter($separator); 
                $objReader->setEnclosure(" ");
                $objReader->setLineEnding($endrow);

                $objPHPExcel = $objReader->load($csv);
                $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
                $objWriter->save($file_location . $filename);               

            }

NB: csv is a string containing comma separated and double quoted fields from the database. The lines end with '\n'.

4

1 回答 1

1

我再次下载了文件并从头开始并开始工作。一定是我做了一些愚蠢的事情,很抱歉浪费了您的时间,并感谢您的帮助。

于 2013-05-16T10:33:18.453 回答