之所以无法访问空房产?

时间:2016-01-05 09:13:21

标签: codeigniter

我是新手......请帮帮我

$ data is object

stdClass Object ( [menu_id] => 38 [menu_code] => M062 [menu_name] => BAP (RICE) [price] => Rp 6.364 [total] => 1

和$ fields是数组,这不是全部..

Array ( [0] => Array ( [code] => menu_id [title] => ID [width] => 5 ) [1] => Array ( [code] => menu_code [title] => Kode [width] => 8 ) [2] => 

这是我的功能:

function writeRowAsli($row, $startChar, $fields, $data){
    $i=$startChar; $j=''; $k='';
    foreach($fields as $field){
        $k = $j.$i;
        $this->excel->getActiveSheet()->setCellValue($k.$row, $data->$field['code']);
        $last = $k;
        if($i == 'Z'){
            $i='A';
            $j.=$i;
        } else $i++;
    }
    $this->excel->getActiveSheet()->setCellValue($j.$i.$row, '=SUM(C'.$row.':'.$k.$row.')');
}

我知道坏行是$ this-> excel-> getActiveSheet() - > setCellValue($ k。$ row,$ data-> $ field [' code']) ; 谢谢所有

1 个答案:

答案 0 :(得分:0)

更改您的功能,如下所示,检查其是否有效:

function writeRowAsli($row, $startChar, $fields, $data){
    $i=$startChar; $j=''; $k='';

    $fields = array_filter($fields);

    foreach($fields as $field){
        $k = $j.$i;
        $this->excel->getActiveSheet()->setCellValue($k.$row, $data->$field['code']);
        $last = $k;
        if($i == 'Z'){
            $i='A';
            $j.=$i;
        } else $i++;
    }
    $this->excel->getActiveSheet()->setCellValue($j.$i.$row, '=SUM(C'.$row.':'.$k.$row.')');
}