0

我正在尝试将变量从数组写入 excel,但在某些情况下我无法写入

代码如下

$workbook =new Spreadsheet_Excel_Writer();
$workbook->send("response.xls");
$row=1;
$col=1;
$workbook->setVersion(8);
$worksheet =& $workbook->addWorksheet('My sheet ');
$Allquestions = $questions->getQuestions();
foreach ($Allquestions as $qkey=>$qval) {
    foreach ($studentResponses as $rval){
        $astresp= $rval->getResponse($qkey);
        //$worksheet->write($row,$col,'hiii');
        $worksheet->write($row, $col, $astresp);
        $col++;
    }
    $row++;
    $col=1;
}
$workbook->close();

$astresp 更改为 'hihi' 时会在 excel 中打印 hihi,但是当它保持为 $astresp 时,它无法打开 excel。

4

0 回答 0