0

From main.php

$id = $_GET['id'];    
<a href="second.php?id=".$id."&name=apple">Excel</a>

How to get the parameters from the url, id and name to Excel and set the cell value dynamically?

Given that there is 2 ids.

Assume that second.php has all the PhpExcel codes.

blakcat7
  • 47
  • 1
  • 13
  • Use `$_GET` array – u_mulder Oct 02 '16 at 18:33
  • Please provide more detail as it is difficult to derive from your question what your actual problem is! – M.S. Oct 02 '16 at 18:36
  • @M.S Supposed that id parameter has 2 values: 1 and 2, I want the two values to be printed out dynamically in excel using phpexcel. So the expected output would b A1, 1 A2, 2 – blakcat7 Oct 02 '16 at 18:41

1 Answers1

0

Try this:

$id = $_GET['id'];
$sheet = $objPHPExcel->getActiveSheet(); //or whatever sheet you like

$index = $sheet->getHighestDataRow();
$sheet->setCellValueByColumnAndRow(0, $index + 1, $id);

(not tested)

Please refer to PHPExcel how to set cell value dynamically for a similar question.

I hope it helps!

Community
  • 1
  • 1
M.S.
  • 312
  • 1
  • 12
  • Hey, sorry for the late reply and thank you for your response. I tried this but it is only printing 1 id instead of 2 – blakcat7 Oct 04 '16 at 20:34
  • @AntheaMarie Hey, no problem at all. I'm sorry that I misunderstood you: Are you aiming to pass those two values inside the same request? Is `?id1=1&id2=2` and then `$id1 = $_GET['id1']; $id2 = $_GET['id2'];` an option? – M.S. Oct 04 '16 at 22:01