phpexcel – on_render_excel

Questionsphpexcel – on_render_excel
Caroline asked 8 years ago

I want to change a data in a cell on export excel. But the event does not appear to occur. My php version is 5.3.3. The export take the filename only. It's my php version? thank!

$grid["export"] = array("format"=>"xls", "filename"=>"my-file", "heading"=>"Export to Excel Test", "range" => "filtered");
$e["on_render_excel"] = array("custom_export", null, false);
$g->set_events($e);

// custom on_export callback function
function custom_export($param)
{
$objPHPExcel = $param["phpexcel"];
$arr = $param["data"];

// column formatting using phpexcel
for($r=1;$r<=count($arr);$r++)
{
$cell = $r+1;
$data = 'Client: '.$arr[$r]["id"];

$objPHPExcel->setActiveSheetIndex(0)
->setCellValue("C$cell","test");
}
}

3 Answers
Abu Ghufran answered 8 years ago

Perhaps, you need to set 3rd param to true.

$e["on_render_excel"] = array("custom_export", null, true);

This will continue default export operation after you function.
As your function does not complete export code, it should be true.

Caroline answered 8 years ago

I try with "true" and nothing change. I received a excel file but the data of column C is not change.

Abu Ghufran answered 8 years ago

You can then make 3rd param to false, and then put complete implementation inside function.
e.g.
https://gist.github.com/gridphp/70e96ee4f0225e2a6af2f76b672b2abf

Your Answer

10 + 3 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?