XLSX To CSV Conversion PHP (Fast & Efficient)

Need Some Help? We are here for you!

We have a very friendly service - Come and chat to us and let us know what you need, we work for an hourly fee and can also provide you a no obligation quote and begin work immediately in most cases. Click "Request Support" or use our Live Chat.

Request Support
This is a mobile optimized version of this page, view original page.

When doing anything these days the very first thing I look for is a resource or library that can do what I need, and for the most part these are better maintained, more thought through and generally a safer bet than hacking / slashing things together yourself. Basically who wants to re-invent the wheel.

However recently I needed to convert an XLSX file to CSV in PHP, I thought this would be super easy since there are many XLSX readers and converter libraries around for many formats including XLSX. You could try PHPEXCEL or the newer library PHPSpreadsheet.

 

Not Efficient

The problem was, the XLSX I was converting was absolutely HUGE, 65,000 rows of data to be exact. And both libraries were using up huge amounts of ram and then failing. I even tried the reader options to read the file in chunks but the library just could not handle all the data and was falling over.

Eventually I realised that even if I could get it to somehow work without failing, it was taking an awfully long time to process the file, and perhaps I needed a more direct, simple and ultimately faster approach.

 

Super Fast XLSX to CSV that can handle huge files

We have built our own script that attach this issue directly (example of how it works below), in the most simplest approach so that dumping out a CSV from an XLSX is super easy and super fast to perform, we have tested our script on huge XLSX files, and we are confident the script runs extremely fast with as minimal resource usage as possible. The function has been updated so you can do any sheet you want to, throttle how many rows you want to process and more.

For just a small fee you can buy our script and use it freely for your projects, whether business or personal. If it doesn’t work for you a full refund can be requested, no problem!

How it works

its easy really, here is our example we include with your purchase:

<?php
    /*
	You can use XLSX2CSV very easily as shown below, just change the paths to the correct paths you need.
	
	*/
	$xlsx_file = '/path/to/file.xlsx';
	$xlsx_unzip_path = '/unpack/here/'; //make sure this is a unique empty folder (especially if using the cleanup)
	$csv_file = '/path/to/result.csv';
	$sheet = 1;
	$throttle = false; //you can set this to ie. 100 to fetch only 100 rows
	$cleanup = true; //if you dont want to cleanup all the junk you can turn this off.
		
	xlsx2csv($xlsx_file, $xlsx_unzip_path, $csv_file, $sheet, $throttle, 0);
?>

 

Need Some Help? We are here for you!

We have a very friendly service - Come and chat to us and let us know what you need, we work for an hourly fee and can also provide you a no obligation quote and begin work immediately in most cases. Click "Request Support" or use our Live Chat.

Request Support

Author: Dean Williams

Professional PHP Web Developer with expertise in OpenCart Web Development, WordPress Web Development, Bespoke Systems - also a seasoned Linux Server Administrator.