从PHPExcel生成数组导入数组到字符串错误

时间:2017-01-30 18:29:19

标签: php phpexcel phpexcelreader

我正在尝试使用PHPExcel从导入的数组填充php中的表。我得到'生成数组到字符串错误'错误。我相信它与将数组转换为字符串有关。该错误表示来自mysqli_stmt_execute($query_mtcelogARRAY);

的行
$mtcelogARRAY = $objPHPExcel->setActiveSheetIndex(2)->rangeToArray('A8:A18');
$num_mtcelog = count($mtcelogARRAY);  // Here get total count of row in that Excel sheet
$mtcelogID = $siteNAME.'.'.$Maindate.'.';
for( $i=0; $i<=$num_mtcelog; $i++ ){
    $sql_mtcelog = "INSERT INTO `maintenance_log`(`mtcelogID`,`mtcelogTYPE`,`MaintenanceID`) VALUES (?,?,?)"; 
    $query_mtcelogARRAY = mysqli_prepare($link, $sql_mtcelog);                  
    mysqli_stmt_bind_param($query_mtcelogARRAY,"sss", $mtcelogID, $mtcelogARRAY[$i], $MaintenanceID);
    mysqli_stmt_execute($query_mtcelogARRAY);
    mysqli_stmt_close($query_mtcelogARRAY);
}
var_dump($mtcelogARRAY);

这是填充表格的方式

enter image description here

我的数组看起来像这样

enter image description here

非常感谢!

1 个答案:

答案 0 :(得分:0)

更改

mysqli_stmt_bind_param($query_mtcelogARRAY,"sss", $mtcelogID, $mtcelogARRAY[$i], $MaintenanceID);

mysqli_stmt_bind_param($query_mtcelogARRAY,"sss", $mtcelogID, $mtcelogARRAY[$i][0], $MaintenanceID);