hello everyone, when i run my php script to transform xlsx file to csv file, i get an error like this:
the PHPExcel version i'm using: 1.7.8
do anyone know how to solve it?
my code as follows:
Fatal error: Uncaught exception 'PHPExcel_Exception' with message 'Sheet1!E2 ->
Invalid cell coordinate A' in C:\xampp-portable\htdocs\xlsx2csv\Classes\PHPExcel
\Cell.php on line 307
PHPExcel_Exception: Sheet1!E2 -> Invalid cell coordinate A in C:\xampp-portable\
htdocs\xlsx2csv\Classes\PHPExcel\Cell.php on line 307
Call Stack:
0.0010 131784 1. {main}() C:\xampp-portable\htdocs\xlsx2csv\Tests\test
.php:0
3.7742 3295200 2. PHPExcel_Writer_CSV->save(string(38)) C:\xampp-portab
le\htdocs\xlsx2csv\Tests\test.php:66
3.8375 3314104 3. PHPExcel_Worksheet->rangeToArray(string(5), string(0)
, bool, ???, ???) C:\xampp-portable\htdocs\xlsx2csv\Classes\PHPExcel\Writer\CSV.
php:140
3.8572 3315336 4. PHPExcel_Cell->getCalculatedValue(???) C:\xampp-porta
ble\htdocs\xlsx2csv\Classes\PHPExcel\Worksheet.php:2415
file used: 123.xlsxthe PHPExcel version i'm using: 1.7.8
do anyone know how to solve it?
my code as follows:
$baseDir = $argv[1];
$outDir = $argv[2];
if(!file_exists($baseDir)){
echo $baseDir . " (the directory doesn't exist!)";
}else{
if(is_dir($baseDir) && $list = opendir($baseDir)){
while($filename = readdir($list)){
$fullName = $baseDir . DIRECTORY_SEPARATOR . $filename;
if(is_file($fullName)){
$fileType = substr(strrchr($filename, '.'),1);
if($fileType == "xlsx" || $fileType == "xls"){
echo "processing: " . $filename . " ..\n";
if($fileType == "xlsx")
$objReader = new PHPExcel_Reader_Excel2007();
else
$objReader = new PHPExcel_Reader_Excel5();
$objReader->setReadDataOnly(true);
$objPHPExcel = $objReader->load($fullName);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'CSV');
$objWriter->save(str_replace('.' . $fileType, '.csv', $outDir . DIRECTORY_SEPARATOR . $filename));
}else{
//echo "file type is: " . $fileType . "\n";
}
}
}
}else{
echo "can't open the directory: " . $baseDir . "\n";
}
}