I use PHPExcel to import data from a .csv file which has the same rows and columns with a excel file. Basically I open them with LibreOffice and they look the same. However there are two result when calculating theirs worksheet dimensions.
I just want to ask that it is always like that due to the different formats or I do something wrong?
$pi = pathinfo($filePath);
switch ($pi['extension']) {
case 'xls':
$reader = PHPExcel_IOFactory::createReader('Excel5');
break;
case 'xlsx':
$reader = PHPExcel_IOFactory::createReader('Excel2007');
break;
case 'csv':
$reader = PHPExcel_IOFactory::createReader('CSV');
break;
default:
return array();
}
$phpexcel = $reader->load($filePath);
$sheet = $phpexcel->getActiveSheet();
$sheet->calculateWorksheetDimension();
When loading a CSV file, if the delimiter isn't a default comma ( ,
) then you need to explicitly set the delimiter for the reader. eg
PHPExcel_IOFactory::createReader('CSV');
$reader->setDelimiter(';');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.