Can anyone guide me how to convert XLS to CSV using PHP?
I have excel spread sheet which contains a list of documents, I want to convert this with CSV format using PHP.
Export Data to Excel with PHP The $data variable holds the data in array format which will be exported to Excel using PHP. ); The filterData() function is used to filter string before added to the excel sheet row. The following code helps to export data in excel and download it as a file.
This will surely work,
require_once 'Classes/PHPExcel/IOFactory.php'; $inputFileType = 'Excel5'; $inputFileName = 'YOUR_EXCEL_FILE_PATH'; $objReader = PHPExcel_IOFactory::createReader($inputFileType); $objPHPExcelReader = $objReader->load($inputFileName); $loadedSheetNames = $objPHPExcelReader->getSheetNames(); $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcelReader, 'CSV'); foreach($loadedSheetNames as $sheetIndex => $loadedSheetName) { $objWriter->setSheetIndex($sheetIndex); $objWriter->save($loadedSheetName.'.csv'); }
Hope this helps...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With