WebDesires - Web Development Cannock, West Midlands
Basket is empty

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
There is a mobile optimized version of this page, view AMP Version.

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

So as always, creating your own super-efficient code wins against packages with many features and complexities, we have created our own functions that perform the conversion with the best performance possible, allowing conversions of large XLSX files super-fast and memory efficient, so when you just simply need to convert an XLSX to a CSV for processing or etc then our script can reliably, quickly and effortlessly convert XLSX files for you allowing your application to process data as you see fit.

Whats more our script allows you to process multiple sheets in an XLSX by allowing you to define which sheet to read out of the file.

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, $cleanup);
?>

 

 

Latest Updates

22/08/19 – 2.1.0 – Fixed a small bug from dropbox editor and how it saves the sharedstrings causing issues with the parser.

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.


Leave a Reply