简体   繁体   中英

PhpExcel: Passing parameters then set cell value dynamically

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.

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!

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