Issue
Alright, So I have this code
$key = $_SESSION['order_nums'];
$sqll = "SELECT * FROM `money` WHERE `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 it setting the cell value for A7 there is about 6 more of those that match. When I do it like this however, It only puts its into the CELL A7
while($fdata=$qq->fetch(PDO::FETCH_ASSOC))
{
$worksheet
->setCellValue('A7', $fdata['code']);
}
How can I make it where The above value will Drop down one cell for each new entry.
So the next would be A8, A9..... and so on.
Solution
That 'A7'
isn't some kind of magic value, it's just a normal PHP string that's passed as a standard function argument to the setCellValue()
method.... you can replace it with a string variable that you define yourself, and change for each row
$column = 'A';
$row = 7;
while($fdata=$qq->fetch(PDO::FETCH_ASSOC))
{
$worksheet
->setCellValue($column . $row, $fdata['code']);
$row++;
}
Answered By - Mark Baker Answer Checked By - Gilberto Lyons (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.