I am working on conversion of excel to csv. And i have currently facing one issue that conversion of excel file with 15k records and it is taking 45 to 50 seconds on average to count the rows and columns of the file.
And if i working with 50k records then system crashes. Here i am not doing any csv conversion work and yes here I am doing only rows and columns count. Is there any way out or any alternative that will solve the issue? Your suggestions are highly appreciated.
require_once('../PHPExcel/Classes/PHPExcel.php');
$start = time();
$infile = 'IMPORT_DATA_15000.xlsx';
$outfile = 'csv/15000.csv';
ini_set('memory_limit', -1);
//Usage:
convertExcel2CSV($infile);
echo 'Time: ' . (time() - $start);
die;
function convertExcel2CSV($infile)
{
// Read your Excel workbook
try
{
$inputFileType = PHPExcel_IOFactory::identify($infile);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($infile);
} catch (Exception $e)
{
die('Error loading file "' . pathinfo($infile, PATHINFO_BASENAME) . '": ' . $e->getMessage());
}
// Get worksheet dimensions
$sheet = $objPHPExcel->getSheet(0);
$highestRow = $sheet->getHighestRow();
$highestColumn = $sheet->getHighestColumn();
echo $highestColumn;
echo "====";
echo $highestRow;
}
OUTPUT:
AMK
====
15000