php bug:failed to open stream: No such file or directory


Warning: include(Classes/PHPExcel.php): 
failed to open stream: No such file or directory in C:\xampp\htdocs\stiterm\new_4.php on line 9

Warning: include(): 
Failed opening 'Classes/PHPExcel.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\stiterm\new_4.php on line 9

Fatal error: Uncaught Error: 
Class 'PHPExcel_IOFactory' not found in C:\xampp\htdocs\stiterm\new_4.php:11 Stack trace: #0 {main} thrown in C:\xampp\htdocs\stiterm\new_4.php on line 11

错误代码

<!DOCTYPE html>
<html>
<head>
<meta http-equiv-"Content-Type" content="text/html; charset=utf-8" />
<title>我的翻译作品</title>
</head>
<body>
<?php
include "Classes/PHPExcel.php";

$excel = PHPExcel_IOFactory::load("Catherine排课17-23.xlsx"); //获取Excel

$sheet = $excel->getActiveSheet(); //获取当前工作表

$highestRow = $sheet->getHighestRow(); //获取行数

$highestColumn = $sheet->getHighestColumn(); //获取列数

echo '<table border="1" width="800" align="center">';

for ($column = "A"; $column <= $highestColumn; $column++)
{
    
    //列数是以A列开始
    for ($row = 0; $row <= $highestRow; $row++)
  {
    
    
        $cell = $sheet->getCell($column . $row)->getValue();

        if($cell instanceof PHPExcel_RichText)
        {
    
     //富文本转换字符串
            $cell = $cell->__toString();
        }

    $namelist = ["George","Emily","Andy","Mia","Vivian"];

    foreach ($namelist as $name)
    {
    
    
      if (strpos($cell,$name) !== false)
      {
    
    
        $cell = str_replace("LT", "", $cell);
        $type = str_replace($name, "", $cell);

        $day = $sheet->getCell($column . "1")->getValue();//孩子上课是星期几

        $date = $sheet->getCell($column . "2")->getValue();

        $finaldate = excelTime($date); //孩子上课是几号

        $time = $sheet->getCell("A" . $row)->getValue();

        $match = timeSplit($time);

        $start = $match[0][0];
        $end = $match[0][1];//孩子上课是几点

        echo '<tr>'.
        '<td>'.$name.'</td>'.
        '<td>'.$type.'</td>'.
        '<td></td>'.
        '<td></td>'.
        '<td>'.$finaldate.'</td>'.
        '<td>'.$start.'</td>'.
        '<td>'.$end.'</td>'.
        '<td>Stacy</td>'.
        '<td>Catherine</td>'.
        '<td>Catherine排课3.2-3.8</td>';

      }
    }
    }
}

echo '</table>';

//转换时间函数

function excelTime($date, $time = false)
{
    
    
    $type1 = strpos($date, '/');
    $type2 = strpos($date, '-');

    if($type1 || $type2)
    {
    
    
        $return_date = $date;
    }else{
    
    
        $return_date=date('d-M',PHPExcel_Shared_Date::ExcelToPHP($date));
    }

        return $return_date;
}


//切分时间段函数

function timeSplit($time)
{
    
    
  preg_match_all('/[0-9]{2}:[0-9]{2}/', $time, $mat);

  return $mat;
}

?>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/weixin_40945354/article/details/108504582