PHPExcel: Dynamic Row and Column incrementing is not working for Array in phpexcel?

这一生的挚爱 提交于 2020-03-06 09:30:22

问题


While printing column and row from an array it's showing blank not exporting any data

$inn_table = "";

if ($result['qualification']['dd1'] != "") {
  $dd1 = explode(",", $result['qualification']['dd1']);
}

if ($result['qualification']['dd2'] != "") {
  $dd2 = explode(",", $result['qualification']['dd2']);
}

for ($i = 0; $i < count($labels); $i++) {

  if ($result['qualification']['dd1'] != "") {
    echo '<pre>First';
    print_r($dd1); ** //echo arrays**
    for ($j = 0; $j < count($dd1); $j++) {
      $temp = explode(">", $dd1[$j]);

      if ($temp[0] == $labels[$i]) {
        $name = explode(">", $dd1[$j]);
        echo '<pre>First ';
        print_r($name[1]); ** //echo names**
      }
    }
  }
}

Here is my Array structure

and Here names which i am trying to export from Array

So i only trying to export names from that array please help


回答1:


foreach($labels as $ind => $label) {

    $index = $ind + 2;

    $letter = range('A', 'Z')[$ind2];
    $val = explode('>', $data);

    $objPHPExcel->getActiveSheet()->setCellValue($letter . $index, $val[1]);

}


来源:https://stackoverflow.com/questions/60164051/phpexcel-dynamic-row-and-column-incrementing-is-not-working-for-array-in-phpexc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!