php - How to dynamically add to PHPExcel spreadsheet -
alright, have code
$key = $_session['order_nums']; $sqll = "select * `money` `order` = :key"; $qq=$con->prepare($sqll); $qq->bindvalue(":key", $key); $qq->execute(); $excel2 = phpexcel_iofactory::createreader('excel2007'); $excel2 = $excel2->load('ntest.xlsx'); // empty sheet $excel2->setactivesheetindex(0); $worksheet = $excel2->getactivesheet(); while($fdata=$qq->fetch(pdo::fetch_assoc)) { $worksheet ->setcellvalue('a7', $fdata['code']); } where it setting cell value a7 there 6 more of match. when however, puts cell a7
while($fdata=$qq->fetch(pdo::fetch_assoc)) { $worksheet ->setcellvalue('a7', $fdata['code']); } how can make above value drop down 1 cell each new entry.
so next a8, a9..... , on.
that 'a7' isn't kind of magic value, it's normal php string that's passed standard function argument setcellvalue() method.... can replace string variable define yourself, , change each row
$column = 'a'; $row = 7; while($fdata=$qq->fetch(pdo::fetch_assoc)) { $worksheet ->setcellvalue($column . $row, $fdata['code']); $row++; }
Comments
Post a Comment