

Most servers or serverless functions fall under this category.

It's the easiest way to convert Excels into CSVs.

If you use Excel or other spreadsheet software, you could open an Excel file and save it as CSV. Any system that could handle text could read CSV. It's because CSVs are nothing more than plain text files. But when it comes to compatibility, CSVs always win. CSVs are far more compatible with any OS or filesystem.Įxcels are awesome.

Troubleshooting: Sometimes conversion fails due to memory issues.You can increase the memory limit, by adding the below line at the start of the file.You would often want to convert Excel files to CSV formats. You can convert XLS to PDF, XLS to CSV, or XLS to HTML by changing the File reader and writer types. Note: You can use the same function to convert XLSX to CSV. $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV') $objPHPExcel = $objReader->load($infile) Putting it All Together: Below is the function to convert XLS to CSV in PHP setReadDataOnly(true) Step 5) Save XLS as CSV $objWriter2007->save("output.csv") Step 4) Create a CSV File Writer $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV') We can get file reader type automatically using $fileType=PHPExcel_IOFactory::identify("input.xls") $objPHPExcel = $objReader->load("input.xls") Įxcel5 -> file format between Excel Version 95 to 2003Įxcel2003XML -> file format for Excel 2003 Step 3) Open Excel file using PHPExcel IOFactory $objReader = PHPExcel_IOFactory::createReader("Excel5") Download PHPExcel library from Github and extract it. In Convert XLS to CSV tutorial, I have explained how to convert XLS to CSV in PHP using PHPExcel Library.įollow the below Steps to convert XLS to CSV.
