I am trying to upload an XLSX file with no luck. If I convert the file to XLS it works great. I am using PHP 5.6 and I have the zip extension enabled. I have verified that the file is being uploaded to the correct location and it has the same permissions as the XLS file. Any ideas would be greatly appreciated.
I am getting the following error messages.
XMLReader::open(): Unable to open source data
Script: /var/www/html/scriptcase/prod/third/phpexcel/PHPExcel/Reader/Excel2007.php (212)
XMLReader::setParserProperty(): Invalid parser property
Script: /var/www/html/scriptcase/prod/third/phpexcel/PHPExcel/Reader/Excel2007.php (213)
XMLReader::read(): Load Data before trying to read
Script: /var/www/html/scriptcase/prod/third/phpexcel/PHPExcel/Reader/Excel2007.php (216)
I am using the example code posted on the the scriptcase website.
require_once(’…/…/…/…’.$this->Ini->path_prod.’/third/phpexcel/PHPExcel.php’);
require_once(’…/…/…/…’.$this->Ini->path_prod.’/third/phpexcel/PHPExcel/IOFactory.php’);
$array_filename = explode(’.’,$this->xlsinput_ul_name);
[table_name] = $array_filename[0];
$fileXlsX = explode(’.’,$this->xlsinput_ul_name);
if($fileXlsX[1]==‘xlsx’){
//xlsx
$inputFileName = “…/…/…/tmp/”.$this->xlsinput_ul_name;
$inputFileType = PHPExcel_IOFactory::identify($inputFileName);
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objPHPExcel = $objReader->load($inputFileName);
$worksheetData = $objReader->listWorksheetInfo("…/…/…/tmp/".$this->xlsinput_ul_name);
$totalRows = $worksheetData[0][‘totalRows’];
$totalColumns = $worksheetData[0][‘totalColumns’];
$lastColumn = $objPHPExcel->getActiveSheet()->getHighestColumn();
$sheet = $objPHPExcel->getSheet(0);
$columnNames="";
$rowDate ="";
for($colum=0;$colum<$totalColumns;$colum++){
if($colum==$totalColumns-1){
$columnNames.= utf8_decode($objPHPExcel->getActiveSheet()->getCellByColumnAndRow($colum, 1)->getValue());
}else{
$columnNames.= utf8_decode($objPHPExcel->getActiveSheet()->getCellByColumnAndRow($colum, 1)->getValue()).",";
}
}
for ($row = 2; $row <= $totalRows; $row++){
for($colum=0;$colum<$totalColumns;$colum++){
if($colum==$totalColumns-1){
$rowDate .= “’”.utf8_decode($objPHPExcel->getActiveSheet()->getCellByColumnAndRow($colum, $row)->getValue())."’";
}else{
$rowDate .= “’”.utf8_decode($objPHPExcel->getActiveSheet()->getCellByColumnAndRow($colum, $row)->getValue())."’,";
}
}
echo “INSERT INTO TABLEA (”.$columnNames.") VALUES (".$rowDate.")";
echo “<br>”;
$rowDate="";
}
}else{
//xls
$objReader = new PHPExcel_Reader_Excel5();
$objReader->setReadDataOnly(false);
$objPHPExcel = $objReader->load("…/…/…/tmp/".$this->xlsinput_ul_name);
$worksheetData = $objReader->listWorksheetInfo("…/…/…/tmp/".$this->xlsinput_ul_name);
$totalRows = $worksheetData[0][‘totalRows’];
$totalColumns = $worksheetData[0][‘totalColumns’];
$lastColumn = $objPHPExcel->getActiveSheet()->getHighestColumn();
$sheet = $objPHPExcel->getSheet(0);
$columnNames="";
$rowDate ="";
for($colum=0;$colum<$totalColumns;$colum++){
if($colum==$totalColumns-1){
$columnNames.= utf8_decode($objPHPExcel->getActiveSheet()->getCellByColumnAndRow($colum, 1)->getValue());
}else{
$columnNames.= utf8_decode($objPHPExcel->getActiveSheet()->getCellByColumnAndRow($colum, 1)->getValue()).",";
}
}
for ($row = 2; $row <= $totalRows; $row++){
for($colum=0;$colum<$totalColumns;$colum++){
if($colum==$totalColumns-1){
$rowDate .= “’”.utf8_decode($objPHPExcel->getActiveSheet()->getCellByColumnAndRow($colum, $row)->getFormattedValue())."’";
}else{
$rowDate .= “’”.utf8_decode($objPHPExcel->getActiveSheet()->getCellByColumnAndRow($colum, $row)->getFormattedValue())."’,";
}
}
echo “INSERT INTO TABLEA (”.$columnNames.") VALUES (".$rowDate.")";
echo “<br>”;}
}