
[EXTENSION]eexcelview http://www.yiiframework.com/extension/eexcelview/
#42
Posted 11 April 2012 - 06:57 AM
#44
Posted 16 April 2012 - 08:09 AM
Above my gridView I have two date inputs and Find button. I select time range and push Find. Page reloads, and in my gridView I can see records between date_from and date_to. But when I try to export this records, page reload again and what I set in date_from and date_to is lost.
And I find another bug:
'columns'=>array( post.number, ...
doesn't work
but
'columns'=>array( array( 'name'=>'post.number', 'value'=>'$data->post->number', ...
works.
#45
Posted 17 April 2012 - 10:31 AM
Preacher, on 09 October 2011 - 11:21 PM, said:
This is my code:
PS The Title doesn't show up on the PDF either.
<?php $bUrl=Yii::app()->baseUrl; $this->widget('application.extensions.EExcelView', array( 'id'=>'pms-grid', 'autoWidth'=>false, 'dataProvider'=>$model->search(), 'title'=>'Preventative Maintenance History', 'exportType'=>'PDF', 'columns'=>array( 'id', 'asset_id', 'type_of_maintenance', 'scheduled_maintenance:boolean', 'unscheduled_maintenance:boolean', 'schduled_date',) )); ?>
Cant find the attached file. Morever, Writer is a folder not a file, so can u kindly point me to where to update?
#46
Posted 25 April 2012 - 04:10 PM
if ($column->type != 'ftext') { $value=$value===null ? "" : $column->grid->getFormatter()->format($value,$column->type); $this->objPHPExcel->getActiveSheet()->setCellValue($this->columnName($a).($row+2) ,$value); } else { $value = $value===null ? "" : $column->grid->getFormatter()->format($value,'text'); $this->objPHPExcel->getActiveSheet()->getCell($this->columnName($a).($row+2))->setValueExplicit($value, PHPExcel_Cell_DataType::TYPE_STRING); }
You can use it by specify the type with the column property : 'type'=>'ftext'
Also, into the xls file you have the value 00012345 and not 12345.
#49
Posted 29 June 2012 - 09:33 AM
I am trying to use this extension without success. Actually I am getting the contents printed in the web page rather than exported to the output stream.
Controller
public function actionExport2excel() { $model = new GeneralProcess(); $this->widget('application.extensions.EExcelView.EExcelView' , array( 'dataProvider' => new CActiveDataProvider ($model , array('pagination'=>false)), 'title'=>"Some title", 'exportType'=>'Excel2007', 'columns'=>array('id','court_process'), )); Yii::app()->end(); }
View
$this->menu=array( array('label'=>'Create Process','url'=>array('create')), array('label'=>'Export To Excel','url'=>array('export2excel')), );
When I click on "Export to Excel" link I will be redirected to the export2excel action and the contents of dataProvider (columns 'id' and 'court_process') are written on the screen.
Am I doing something wrong?
Thanks for the help
A.Miguel
#50
Posted 29 June 2012 - 01:51 PM
....
'grid_mode'=>'export',
.....
@banamlehsb: that's not possible at the moment. May I can think of some callback function to render the header and footer. Or may be I can return the excel object so you can add anything with your own code.
#52
Posted 20 July 2012 - 08:41 PM
#53
Posted 23 July 2012 - 02:17 AM
Can I format output of the excel file? I want to bold the header row and change the font of the table.
#55
Posted 23 July 2012 - 07:09 AM
Nikolay Yanev, on 23 July 2012 - 02:17 AM, said:
Can I format output of the excel file? I want to bold the header row and change the font of the table.
Well formatting excel tables might be quite specific to any user/project. So I've created callback functions when rendering headers and rows. So you can create a callback function for onRenderHeaderCell(PHPExcel_Cell $cell, string $value) and use the $cell to do whatever you want, see PHPExcel's documentation for more info.
#56
Posted 24 July 2012 - 02:18 AM
phreak, on 23 July 2012 - 07:09 AM, said:
Where should I place this code?
#57
Posted 26 July 2012 - 08:08 AM
Nikolay Yanev, on 24 July 2012 - 02:18 AM, said:
You create of function in you controller onRenderHeaderCell(PHPExcel_Cell $cell, string $value) then when you init the widget , you do it like this:
$this->widget(.....
'onRenderHeaderCell'=>array($this, 'onRenderHeaderCell'),
....);
#58
Posted 27 July 2012 - 11:34 AM
russellfeeed, on 26 March 2012 - 10:29 AM, said:
I did some ugly hacking in the EExcelView::renderRow() method. Not very nice but it suited my need for that time.
public function renderRow($row) { $data=$this->dataProvider->getData(); if(!$this->showHeader) $offset = 1; else $offset = 0; $a=0; foreach($this->columns as $n=>$column) { if($column->value!==null) $value=$this->evaluateExpression($column->value ,array('data'=>$data[$row])); else if($column->name!==null) $value=$data[$row][$column->name]; $value=$value===null ? "" : $column->grid->getFormatter()->format($value,$column->type); $a++; if($column->type=='text') $this->objPHPExcel->getActiveSheet()->setCellValueExplicit($this->columnName($a).($row+2-$offset), $value, PHPExcel_Cell_DataType::TYPE_STRING); else $this->objPHPExcel->getActiveSheet()->setCellValue($this->columnName($a).($row+2-$offset), $value); if(substr($value,'\n')) $this->objPHPExcel->getActiveSheet()->getStyle($this->columnName($a).($row+2-$offset))->getAlignment()->setWrapText(true); if(isset($column->cssClassExpression)) { $css = $this->evaluateExpression($column->cssClassExpression,array('data'=>$data[$row])); if($css=='red') { $background = 'FF0000'; $font = 'FFFFFF'; } else if($css=='yellow') { $background = 'FFFF00'; $font = '000000'; } else if($css=='green') { $background = '008000'; $font = 'FFFFFF'; } else { $background = 'FFFFFF'; $font = '000000'; } $this->objPHPExcel->getActiveSheet()->getStyle($this->columnName($a).($row+2-$offset))->applyFromArray( array( 'font' => array( 'bold' => true, 'color' => array( 'rgb' => $font ) ), 'fill' => array( 'type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => $background) ), )); $this->objPHPExcel->getActiveSheet()->getStyle($this->columnName($a).($row+2-$offset))->getAlignment() ->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER)->setVertical(PHPExcel_Style_Alignment::VERTICAL_TOP); } $this->_lastCell = $this->columnName($a).($row+2-$offset); } }
#59
Posted 01 August 2012 - 02:30 PM
#60
Posted 01 August 2012 - 02:55 PM
rikim1228, on 01 August 2012 - 02:30 PM, said:
I was able to figure it out on my own but am still trying to get the actual exporting to happen now.