简体   繁体   中英

PHPExcel not display all rows using php

In excel sheet, I cannot display all rows of table.My following code display only first row.

$sql="SELECT * FROM projects";
$result=mysqli_query($con,$sql);
$row = 1; 
while($row_data = $result->fetch_assoc()) {
    $col = 0;
    foreach($row_data as $key=>$value) {
        $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $value);
        $col++;
    }
    $row++;
}

TRY THIS,CHANGE ROW AND COL VARIABLE

$sql="SELECT * FROM projects";
$result=mysqli_query($con,$sql);
$row = 1; 
while($row_data = $result->fetch_assoc()) {
  $col = 0;
  foreach($row_data as $key=>$value) {
    $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $value);
    $row++;
  }           
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM