Yii Framework Forum: eexcelview extentions with pdf library - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

eexcelview extentions with pdf library 1.8.0 Phpexcel with eexcelview extention

#1 User is offline   chandran 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 544
  • Joined: 08-October 12
  • Location:Austria

Posted 22 April 2015 - 09:28 AM

I am currently using 1.8.0 phpexcel..but this little bit tricky..

1.8.0 does not have inbuild pdf library so we have to load external library like mpdf , htmlpdf, tcpdf

so download from any one vendor site and copy the folder into /protected/vendor folder

Then goto eexcelview init method and replace with this code.

what i did here is simple

i am loading rendererName and rendererLibraryPath , then i am calling setPdfRenderer of phpexcel.. It will inform


hi phpexcel i am going to use mpdf and you can load library from this renderer path :)


Have Fun


public function init()
		{
			if(isset($_GET[$this->grid_mode_var]))
				$this->grid_mode = $_GET[$this->grid_mode_var];
			if(isset($_GET['exportType']))
				$this->exportType = $_GET['exportType'];

			$lib = Yii::getPathOfAlias($this->libPath).'.php';
			if($this->grid_mode == 'export' and !file_exists($lib)) {
				$this->grid_mode = 'grid';
				Yii::log("PHP Excel lib not found($lib). Export disabled !", CLogger::LEVEL_WARNING, 'EExcelview');
			}

			if($this->grid_mode == 'export')
			{
				$this->title = $this->title ? $this->title : Yii::app()->getController()->getPageTitle();
				$this->initColumns();
				//parent::init();
				//Autoload fix
				spl_autoload_unregister(array('YiiBase','autoload'));
				Yii::import($this->libPath, true);

				$this->objPHPExcel = new PHPExcel();
				$rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF;
				$rendererLibraryPath = Yii::app()->basePath . '/vendor/mpdf60';
				//  Here's the magic: you __tell__ PHPExcel what rendering engine to use
				// 	and where the library is located in your filesystem
				if (!PHPExcel_Settings::setPdfRenderer($rendererName,$rendererLibraryPath)) {
					die('NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
							'<br />' .
							'at the top of this script as appropriate for your directory structure'
					);
				}

				spl_autoload_register(array('YiiBase','autoload'));
				// Creating a workbook
				$this->objPHPExcel->getProperties()->setCreator($this->creator);
				$this->objPHPExcel->getProperties()->setTitle($this->title);
				$this->objPHPExcel->getProperties()->setSubject($this->subject);
				$this->objPHPExcel->getProperties()->setDescription($this->description);
				$this->objPHPExcel->getProperties()->setCategory($this->category);
			} else
				parent::init();
		}



I hope it will help others who are trying to upgrade 1.7 phpexcel to 1.8.0 (only pdf required this settings)
Thanks
chandran nepolean

My own extension:
http://www.yiiframew...sion/ejqueryte/
http://www.yiiframew...uallistboxyii1/

My wiki
http://www.yiiframew...checkboxcolumn/

If it work dont hesitate to click +1 button
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users