Yii Framework Forum

Eexcelview Export Multiple Table In Same Page


(Balajisankar) #1

im using this extension to export date to excel

i have using dynamic table generation

my view code

$dataprovider = new CArrayDataProvider($item[‘content’], array(

'id'=>'id',


'sort'=>array( ),


'pagination'=>array(


    'pageSize'=>10,


),

));

$columns = array();

$values = $dataprovider->getData();

if(isset($values[0])){

foreach($values[0] as $key=>$val){


  if($key!="id")


   $columns[] = array("name"=>$key,"value"=>'$data["'.$key.'"]',"type"=>"raw","header"=>isset($item['headerlabel'][$key])?$item['headerlabel'][$key]:$key); 


}

}

$this->widget(‘ext.EExcelView.EExcelView’,

array( "summaryText"=>false,

  'dataProvider'=>$dataprovider,


   'columns'=>$columns,


  'itemsCssClass' => 'table table-striped',


   'template'=>"{summary}\n{items}\n{exportbuttons}\n{pager}",


 'htmlOptions'=>array("class"=>"report_grid_view report_grid_portlet_view")


  )


);

the export link is append to each and every table but exporting the first table data only , if i click the 2nd 3rd or 4th i click it will export 1st table data only , what mistake i did


(Louisgac Development) #2

Well, very first thing : $dataprovider should be defined in your controller or in your model, not in your view.

Second thing :




if($key!="id")

$columns[] = array("name"=>$key,"value"=>'$data["'.$key.'"]',"type"=>"raw","header"=>isset($item['headerlabel'][$key])?$item['headerlabel'][$key]:$key); 

}



It miss one bracket "{" after the if

And what the hell is this condition ?


array("name"=>$key,"value"=>'$data["'.$key.'"]',"type"=>"raw","header"=>isset($item['headerlabel'][$key])?$item['headerlabel'][$key]:$key); 

If you can’t read it, you can’t debug it.

So please, replace this Ternary Operator by something humanly readable.

And please, provide two raws of your excel.


(Louisgac Development) #3

If your code is not very clean, who can help you ?

Having a messy code is always a bad idea, and source of many bugs.

Please, use brackets, indentation, and use the Ternary Operator with extreme caution, only for trivial conditions easily readable.

And please, provide some example of your data.


(danyaalhallak) #4

please i have the same bugs

i use EEXcel extension do you have any idea how i can solve this problem