[英]PHPExcel calculateWorksheetDimension of a csv file
I use PHPExcel to import data from a .csv file which has the same rows and columns with a excel file. 我使用PHPExcel从.csv文件导入数据,该文件与Excel文件具有相同的行和列。 Basically I open them with LibreOffice and they look the same.
基本上,我使用LibreOffice打开它们,它们看起来相同。 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. 加载CSV文件时,如果定界符不是默认的逗号(
,
),则需要为阅读器显式设置定界符。 eg 例如
PHPExcel_IOFactory::createReader('CSV');
$reader->setDelimiter(';');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.