尝试从db保存Excel文件数据时出错

时间:2017-07-12 20:46:56

标签: php mysql

我收到了错误

  

警告:ZipArchive :: close():无法创建临时文件:第388行/Applications/XAMPP/xamppfiles/htdocs/carpha/Classes/PHPExcel/Writer/Excel2007.php中的权限被拒绝

  

致命错误:未捕获的异常' PHPExcel_Writer_Exception'有消息'无法关闭zip文件/Users/nigel/file.xlsx.'在

我的代码:

$sql = "SELECT * FROM rec_proposal where 1";

$result = $db->conn->prepare($sql);

$objPHPExcel = new PHPExcel(); 

// Set the active Excel worksheet to sheet 0
$objPHPExcel->setActiveSheetIndex(0); 

// Initialise the Excel row number
$rowCount = 1; 

$result->execute();

while($row =$result->fetch(PDO::FETCH_ASSOC))
{ 

    $objPHPExcel->getActiveSheet()->SetCellValue('A'.$rowCount, $row['ProposalID']);
    $objPHPExcel->getActiveSheet()->SetCellValue('B'.$rowCount, $row['UserID']);
    $objPHPExcel->getActiveSheet()->SetCellValue('C'.$rowCount, $row['ProposalName']);

}

$objWriter =  new PHPExcel_Writer_Excel2007($objPHPExcel); 

$objWriter->save('/Users/file.xlsx'); 

0 个答案:

没有答案