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.
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...
1.4m articles
1.4m replys
5 comments
57.0k users