使用php excel导出excel文件中的mysql数据

时间:2017-11-05 12:53:16

标签: php mysql phpexcel

在从针对mysql表的查询中使用PHPExcel生成excel文件时出现错误 致命错误:'break'不在第574行的C:\ xampp \ htdocs \ Classes \ PHPExcel \ Calculation \ Functions.php中的'loop'或'switch'上下文中

我的PHP代码是

<?php
include 'connection.php'; 
require_once '../../../Classes/PHPExcel.php';
mysqli_set_charset($conn,'utf8');
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0);
$query =  "SELECT question_name FROM current_affairs_question_details where id='$_GET[currentaffairid]' limit 0,20";  
$result = mysqli_query($conn,$query);
$rowcount=1;
while($row = mysqli_fetch_array($result)){
    $objPHPExcel->getActiveSheet()->SetCellValue('A'.$rowcount, $row['question_name']);
    $rowcount++;
}
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save('some_excel_file.xlsx');

?>

0 个答案:

没有答案