php类导入excel到mysql错误

时间:2016-12-23 10:39:26

标签: php mysql excel

我使用这个库将excel数据导入mysql数据库

excel to mysql

这个库在localhost上工作正常,一切正常

但当我将我的文件上传到godaddy上的主机时,我在尝试在线测试代码时收到此错误

  

致命错误:Class' ZipArchive'在第94行的/home/mhmd2991/public_html/PHPExcel/Reader/Excel2007.php中找不到

这是代码:

if(isset($_POST['btnImport'])){
    if(!empty($_FILES['ecxelfile']['tmp_name'])){
        $fileName=explode(".",$_FILES['ecxelfile']['name']);
        if($fileName[1]=="xls" || $fileName[1]=="xlsx"){
         $file=$_FILES['ecxelfile']['tmp_name'];
include("../PHPExcel/IOFactory.php");
$objPHPExcel=PHPExcel_IOFactory::load($file);
foreach($objPHPExcel->getWorksheetIterator() as $worksheet){
    $highestRow=$worksheet->getHighestRow();
    for($row=2;$row<=$highestRow;$row++){
$A =mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(0,$row)->getValue());
$category =mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(1,$row)->getValue());
$AA=mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(2,$row)->getValue());
$AAA=mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(3,$row)->getValue());
$taskname=mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(4,$row)->getValue());
$predecessors=mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(5,$row)->getValue());
$unit=mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(6,$row)->getValue());
$qty=mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(7,$row)->getValue());
$wo=mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(8,$row)->getValue());
$duration=mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(9,$row)->getValue());
$startdate=mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(10,$row)->getValue());
$enddate=mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(11,$row)->getValue());
$asd=mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(12,$row)->getValue());
$add=mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(13,$row)->getValue());
$aduration=mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(14,$row)->getValue());
$transferredto=mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(15,$row)->getValue());
$prb=mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(16,$row)->getValue());
$anotes=mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(17,$row)->getValue());
$user=mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(18,$row)->getValue());
$projectname=mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(19,$row)->getValue()); 
$subcategory=mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(20,$row)->getValue());  
$client=mysqli_real_escape_string($conn,$worksheet->getCellByColumnAndRow(21,$row)->getValue());
 $query=mysqli_query($conn,"insert into tbl_activities (db_A,db_category,db_AA,db_AAA,db_taskname,db_predecessors,db_unit,db_qty,db_wo,db_duration,db_startdate,db_enddate,db_asd,db_add,db_aduration,db_transferredto,db_prb,db_anotes,db_user,db_projectname,db_subcategory,db_client) values('$A', '$category','$AA','$AAA','$taskname','$predecessors','$unit','$qty','$wo','$duration','$startdate','$enddate','$asd','$add','$aduration','$transferredto','$prb','$anotes','$user','$projectname','$subcategory','$client')")or die(mysqli_error($conn)); 
    }
}
header("location:activitiesimport.php?msg=1");
        }else{echo"You Should upload an excel file.";}
    }else{echo"Please choose a file";}
}

任何一个有这个库的经验可以帮我解决这个问题吗?

0 个答案:

没有答案