Error while converting xlsx to csv in Ubuntu environment

Topics: Developer Forum, Project Management Forum, User Forum
Oct 12, 2012 at 9:48 AM

Hi Mark

i have customized a code and using it for the conversion of xlsx file to csv. which is working fine in windows xp but it is showing this error when i execute it in ubuntu os

Fatal error: Uncaught exception 'Exception' with message 'ZipArchive library is not enabled' in /opt/lampp/htdocs/testingcsv/PHPExcel/Reader/Excel2007.php:241 Stack trace: #0 /opt/lampp/htdocs/testingcsv/PHPExcel/IOFactory.php(258): PHPExcel_Reader_Excel2007->canRead('test.xlsx') #1 /opt/lampp/htdocs/testingcsv/PHPExcel/IOFactory.php(206): PHPExcel_IOFactory::createReaderForFile('test.xlsx') #2 /opt/lampp/htdocs/testingcsv/csv_check.php(13): PHPExcel_IOFactory::identify('test.xlsx') #3 {main} thrown in /opt/lampp/htdocs/testingcsv/PHPExcel/Reader/Excel2007.php on line 241

above error is referencing to following code segment of Excel2007.php file which is

    // Check if zip class exists
        if (!class_exists('ZipArchive')) {
            throw new Exception("ZipArchive library is not enabled");

Then i gone through ur post and put this code to enable it


then i downloaded zziplib-0.13.59.tar.bz2 file but i could not use it.
Kindly Suggest any solution.

Oct 13, 2012 at 10:14 PM
Edited Oct 13, 2012 at 10:18 PM

ZipArchive is a prerequisite for running PHPExcel when using zipped file formats such as xlsx. PCLZip is currently only provided as an alternative for writing, not for reading.

You need to install a version of PHP with ZipArchive, or rebuild the PHP from source with --enable-zip

Oct 14, 2012 at 12:00 PM
Edited Oct 14, 2012 at 3:38 PM

okay. i have downloaded zziplib-0.13.59.tar.bz2 but after the extraction of this file what we need to do in order to install it? and do we need to uncomment the zip extension in php.ini file also? and one more thing i want to ask, if this is the exact issue then why it is working properly in window XP OS. i am using XAMP in Ubuntu. how to rebuild the PHP from source with --enable-zip?

Oct 14, 2012 at 4:09 PM

The link in my message to the Installation details for ZipArchive should explain exactly what you need to do to enable ZipArchive in your PHP.

Clearly your Windows version of PHP is configured differently to your XAMP on Ubuntu... phpinfo() is a very useful function for detailing the PHP configuration on a server.