Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/155.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
在PHPExcel中将动态单元格和行数据一起打印时出错?_Php_Phpexcel_Phpexcel 1.8.0 - Fatal编程技术网

在PHPExcel中将动态单元格和行数据一起打印时出错?

在PHPExcel中将动态单元格和行数据一起打印时出错?,php,phpexcel,phpexcel-1.8.0,Php,Phpexcel,Phpexcel 1.8.0,您好,当打印动态列的名称时,一切都是正确的,没有出现任何错误,但当打印一行动态数据时,我只在代码的两个位置出现错误,我还在出现错误的地方添加了一条注释,请检查一次,并向我建议一些方法- 动态列代码- $out_table = ''; $k = 0; mysql_data_seek($query_result1, 0); $col = 36; while ($row1 = mysql_fetch_array($query_result1, MYSQL_ASSOC)

您好,当打印动态列的名称时,一切都是正确的,没有出现任何错误,但当打印一行动态数据时,我只在代码的两个位置出现错误,我还在出现错误的地方添加了一条注释,请检查一次,并向我建议一些方法-

动态列代码-

 $out_table = '';
    $k = 0;
    mysql_data_seek($query_result1, 0);
    $col = 36;
    while ($row1 = mysql_fetch_array($query_result1, MYSQL_ASSOC)) {
        $sheet->setCellValueByColumnAndRow($col, 1, trim($labels[$k] . " (value1)", ','));
        $sheet->setCellValueByColumnAndRow($col + 1, 1, trim($labels[$k] . " (value2)", ','));
        $col = $col + 2;
        $k++;
    }

    echo $out_table; 
    $inn_table = "";


    if (isset($result['qualification']['dd1'])) {

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

        if ($result['qualification']['dd2'] != "") {
            $dd2 = explode(",", $result['qualification']['dd2']);
        }
    }
    for ($i = 0; $i < count($labels); $i++) {
        if (isset($temp)) {
            if ($result['qualification']['dd1'] != "") {
                $found = false;
                for ($j = 0; $j < count($dd1); $j++) {
                    $temp = explode(">", $dd1[$j]);


                    if ($temp[0] == $labels[$i]) {
                        $name = explode(">", $dd1[$j]);
                        $inn_table .= '<td>' . $name[1] . '</td>'; **if i comment it getting no error also no data**
                        //  echo '<pre>ass';print_r($dd1);die();
                        $found = true;
                        break;
                    }
                }
                if (!$found)
                    $inn_table .= "<td>&nbsp;</td>";
            }
        } else
            $inn_table .= "<td>&nbsp;</td>";
        if (isset($result['qualification']['dd2'])) {
            if ($result['qualification']['dd2'] != "") {
                $found = false;
                  echo '<pre>ass';print_r($dd2);die;
                if (isset($temp)) {
                    for ($j = 0; $j < count($dd2); $j++) {
                        $temp = explode(">", $dd2[$j]);
                        if ($temp[0] == $labels[$i]) {
                            $name = explode(">", $dd2[$j]);
                              $inn_table .= '<td>' . $name[1] . '</td>'; **if i comment it getting no error also no data**

                            $found = true;
                            break;
                        }
                    }
                }
                if (!$found)
                    $inn_table .= '<td>&nbsp;</td>';
            }
        } else {

            $inn_table .= '<td>&nbsp;</td>';
        }
    }
      echo $inn_table;

     echo "</tr>";

} 
但在打印列的动态数据时,我遇到了错误-

 $out_table = '';
    $k = 0;
    mysql_data_seek($query_result1, 0);
    $col = 36;
    while ($row1 = mysql_fetch_array($query_result1, MYSQL_ASSOC)) {
        $sheet->setCellValueByColumnAndRow($col, 1, trim($labels[$k] . " (value1)", ','));
        $sheet->setCellValueByColumnAndRow($col + 1, 1, trim($labels[$k] . " (value2)", ','));
        $col = $col + 2;
        $k++;
    }

    echo $out_table; 
    $inn_table = "";


    if (isset($result['qualification']['dd1'])) {

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

        if ($result['qualification']['dd2'] != "") {
            $dd2 = explode(",", $result['qualification']['dd2']);
        }
    }
    for ($i = 0; $i < count($labels); $i++) {
        if (isset($temp)) {
            if ($result['qualification']['dd1'] != "") {
                $found = false;
                for ($j = 0; $j < count($dd1); $j++) {
                    $temp = explode(">", $dd1[$j]);


                    if ($temp[0] == $labels[$i]) {
                        $name = explode(">", $dd1[$j]);
                        $inn_table .= '<td>' . $name[1] . '</td>'; **if i comment it getting no error also no data**
                        //  echo '<pre>ass';print_r($dd1);die();
                        $found = true;
                        break;
                    }
                }
                if (!$found)
                    $inn_table .= "<td>&nbsp;</td>";
            }
        } else
            $inn_table .= "<td>&nbsp;</td>";
        if (isset($result['qualification']['dd2'])) {
            if ($result['qualification']['dd2'] != "") {
                $found = false;
                  echo '<pre>ass';print_r($dd2);die;
                if (isset($temp)) {
                    for ($j = 0; $j < count($dd2); $j++) {
                        $temp = explode(">", $dd2[$j]);
                        if ($temp[0] == $labels[$i]) {
                            $name = explode(">", $dd2[$j]);
                              $inn_table .= '<td>' . $name[1] . '</td>'; **if i comment it getting no error also no data**

                            $found = true;
                            break;
                        }
                    }
                }
                if (!$found)
                    $inn_table .= '<td>&nbsp;</td>';
            }
        } else {

            $inn_table .= '<td>&nbsp;</td>';
        }
    }
      echo $inn_table;

     echo "</tr>";

} 
$inn_table=”“;
如果(isset($result['qualification']['dd1'])){
如果($result['qualification']['dd1']!=“”){
$dd1=爆炸(“,”,$result['qualification']['dd1']);
}
}
如果(isset($result['qualification']['dd2'])){
如果($result['qualification']['dd2']!=“”){
$dd2=爆炸(“,”,$result['qualification']['dd2']);
}
}
对于($i=0;$i”,$dd1[$j]);
如果($temp[0]=$labels[$i]){
$name=explode(“>”,$dd1[$j]);
$inn_table.=''.$name[1].';**如果我对其进行注释,则不会得到任何错误,也不会得到任何数据**
//echo'ass';print_r($dd1);die();
$found=true;
打破
}
}
如果(!$found)
$inn_table.=”;
}
}否则
$inn_table.=”;
如果(isset($result['qualification']['dd2'])){
如果($result['qualification']['dd2']!=“”){
$found=false;
回声“屁股”;打印(dd2美元);死亡;
如果(isset($temp)){
对于($j=0;$j”,$dd2[$j]);
如果($temp[0]=$labels[$i]){
$name=explode(“>”,$dd2[$j]);
$inn_table.=''.$name[1].';**如果我对其进行注释,则不会得到任何错误,也不会得到任何数据**
$found=true;
打破
}
}
}
如果(!$found)
$inn_table.='';
}
}否则{
$inn_table.='';
}
}
echo$inn_table;
回声“;
} 

如何在不启动的情况下追加
或定义
标记?这不是正确的方法,您应该始终发布您希望我们帮助您的完整错误消息。不要让我们阅读所有代码并猜测。@Gulshan您能建议我如何编写$inn_table.=''$名称[1]。';在phpexcel表单中?@Utsaww在excel中添加
td
的要求是什么。大多数情况下,我们都是以excel格式将数据添加到列中。实际上,我们在这里做什么?我正在将数据添加到列中,但我不知道如何以phpexcel格式添加数据,因为它不包含td