PHPExcel如何使用codeigniter动态设置单元格值

PHPExcel如何使用codeigniter动态设置单元格值,php,codeigniter,Php,Codeigniter,我无法修复代码中的错误。它产生一个数据。我需要的是使用这些行循环并从数据库中获取所有数据 控制器 function firstDebit(){ $series=$this->uri->segment(3); $this->db->select ( 'accountcode.accountName' ); $this->db->from ( 'accountcode' ); $this->db->join ( 'generalaccount ',

我无法修复代码中的错误。它产生一个数据。我需要的是使用这些行循环并从数据库中获取所有数据

控制器

function firstDebit(){
$series=$this->uri->segment(3); 

$this->db->select ( 'accountcode.accountName' );
$this->db->from ( 'accountcode' );
$this->db->join ( 'generalaccount ', 'generalaccount.AccountCode = accountcode.id');
$this->db->where ( 'generalaccount.Series', $series);
$this->db->where ( 'generalaccount.Account', 'debit');
$this->db->where ( 'generalaccount.Count', 1);
$query = $this->db->get();
$query->row_array();

$rowNumber=10;

foreach($query->row_array() as $rows){
     $this->excel->setCellValue('b'.$rowNumber, $rows);
     $rowNumber++;

}

}

我认为您需要的是结果数组,这样您的代码就可以

function firstDebit(){
    $series=$this->uri->segment(3); 

    $this->db->select ( 'accountcode.accountName' );
    $this->db->from ( 'accountcode' );
    $this->db->join ( 'generalaccount ', 'generalaccount.AccountCode = accountcode.id');
    $this->db->where ( 'generalaccount.Series', $series);
    $this->db->where ( 'generalaccount.Account', 'debit');
    $this->db->where ( 'generalaccount.Count', 1);
    $query = $this->db->get();

    $rowNumber=10;

    foreach($query->result_array() as $rows){
         $this->excel->setCellValue('b'.$rowNumber, $rows['accountName']);
         $rowNumber++;

    }
}

我使用了对开本,但它产生了一个错误。遇到PHP错误严重性:注意消息:未定义的偏移量:0文件名:Cell/DefaultValueBinder.PHP行号:82回溯:文件:C:\xampp\htdocs\acc\application\third\u party\phpexel\Cell\DefaultValueBinder.PHP行:82函数:_Error\u handler是使用结果数组的结果,必须使用$rows['accountName']作为单元格值。