Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PHP Excel从Excel文件导入数据_Php_Phpexcel - Fatal编程技术网

使用PHP Excel从Excel文件导入数据

使用PHP Excel从Excel文件导入数据,php,phpexcel,Php,Phpexcel,我试图从excel工作表导入一些数据,但我的一个变量(级别)不起作用。我希望有人能看看为什么这一个不起作用,但事件和部门 class CompetitionClass { public $event; public $division; public $level; function __construct(){ $this->entryTable = array(); } } $x++; $compClass[$x] = new Co

我试图从excel工作表导入一些数据,但我的一个变量(级别)不起作用。我希望有人能看看为什么这一个不起作用,但事件和部门

class CompetitionClass 
{
   public $event;
   public $division;
   public $level;

   function __construct(){

      $this->entryTable = array();
   }
}



$x++;
$compClass[$x] = new CompetitionClass();
$compClass[$x] -> event = htmlspecialchars((string)$objPHPExcel->getSheet($key)->getCell('F1')->getOldCalculatedValue());
$compClass[$x] -> division = htmlspecialchars((string)$objPHPExcel->getSheet($key)->getCell('H1')->getOldCalculatedValue());
$compClass[$x] -> level = htmlspecialchars((string)$objPHPExcel->getSheet($key)->getCell('F2')->getOldCalculatedValue());



foreach($compClass as $key => $value)
{
   if($value -> division == "MOD")
   {
       print(strtoupper($value -> event)."&nbsp;&nbsp;&nbsp; ".strtoupper($value -> level)."&nbsp;&nbsp;&nbsp; ".strtoupper($value -> division)."<BR/>");
   } 
班级竞赛班级
{
公共活动;
公共财政司;
公帑水平;;
函数_u构造(){
$this->entryTable=array();
}
}
$x++;
$compClass[$x]=新的CompetitionClass();
$compClass[$x]->event=htmlspecialchars((字符串)$objPHPExcel->getSheet($key)->getCell('F1')->getoldculatedvalue());
$compClass[$x]->division=htmlspecialchars((字符串)$objPHPExcel->getSheet($key)->getCell('H1')->getoldculatedvalue());
$compClass[$x]->level=htmlspecialchars((字符串)$objPHPExcel->getSheet($key)->getCell($F2')->getoldculatedvalue());
foreach($compClass作为$key=>$value)
{
如果($value->division==“MOD”)
{
打印(strtoupper($value->event)。“”.strtoupper($value->level)。“”.strtoupper($value->除法)。“
”; }

}

我必须更改readCell函数,使其包含第2行,而不仅仅是第1行

这是我在改变之前的经历:

class MyReadFilter implements PHPExcel_Reader_IReadFilter
{
   public function readCell($column, $row, $worksheetName = '')
   {
      if (($row == 1 and in_array($column, range('F','H'))) or ($row >= 3 and $row <= 25 and in_array($column, range('G','N'))))
         { return true; }
      return false;
   }
}
class MyReadFilter implements PHPExcel_Reader_IReadFilter
{
   public function readCell($column, $row, $worksheetName = '')
   {
      if (($row >= 1 and $row <= 2 and in_array($column, range('F','H'))) or ($row >= 3 and $row <= 25 and in_array($column, range('G','N'))))
         { return true; }
      return false;
   }
}
类MyReadFilter实现PHPExcel\u Reader\u IReadFilter
{
公共函数readCell($column,$row,$worksheetName='')
{

如果($row==1和in_数组($column,range('F','H'))或($row>=3和$row=1,$row=3和$row=1,$row=1和$row)看起来很好,那么很难从这个有限的角度说什么information@Viney我发现我必须将readCell函数更改为包含第2行,而不仅仅是第1行。请在问题中给出解释。