Yii Framework Forum: Toexcel Export - Yii Framework Forum

Jump to content

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

Toexcel Export Rate Topic: ***** 1 Votes

#1 User is offline   bardoo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 30-January 13

Posted 24 February 2013 - 06:06 AM

Hi,
i'm using the EExcelBeahvior extension to export to excel, the problem is that i can't find the generated file?
my action is :
$model = MyModel::model()->findByPk('20');
		$this->toExcel($model,
			array(
				'id',
				),
			'report',
			array('creator'=>'me'),
			'Excel2007'
		);
		$dataProvider=new CActiveDataProvider('MyModel');
		$this->render('index',array(
			'dataProvider'=>$dataProvider,
		));

Thanks
HOPE IS A GOOD THING, MAYBE THE BEST THINGS, AND NO GOOD THING EVER DIES.
0

#2 User is offline   yiqing95 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 591
  • Joined: 27-December 10
  • Location:china

Posted 24 February 2013 - 06:23 AM

read the source code ! this extension can both saving to a file and as a download file

	//create writer for saving
			$objWriter = PHPExcel_IOFactory::createWriter(self::$objPHPExcel, $this->exportType);
			if(!$this->stream)
				$objWriter->save($this->filename);
			else //output to browser
			{
				if(!$this->filename)
					$this->filename = $this->title;
				ob_end_clean();
				header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
				header('Pragma: public');
				header('Content-type: '.$this->mimeTypes[$this->exportType]['Content-type']);
				header('Content-Disposition: attachment; filename="'.$this->filename.'.'.$this->mimeTypes[$this->exportType]['extension'].'"');
				header('Cache-Control: max-age=0');
				$objWriter->save('php://output');
				die() ;  //Yii::app()->end();
			}


this is how this extension handle the exported result :lol:
1

#3 User is offline   bardoo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 30-January 13

Posted 24 February 2013 - 10:22 AM

View Postyiqing95, on 24 February 2013 - 06:23 AM, said:

read the source code ! this extension can both saving to a file and as a download file

	//create writer for saving
			$objWriter = PHPExcel_IOFactory::createWriter(self::$objPHPExcel, $this->exportType);
			if(!$this->stream)
				$objWriter->save($this->filename);
			else //output to browser
			{
				if(!$this->filename)
					$this->filename = $this->title;
				ob_end_clean();
				header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
				header('Pragma: public');
				header('Content-type: '.$this->mimeTypes[$this->exportType]['Content-type']);
				header('Content-Disposition: attachment; filename="'.$this->filename.'.'.$this->mimeTypes[$this->exportType]['extension'].'"');
				header('Cache-Control: max-age=0');
				$objWriter->save('php://output');
				die() ;  //Yii::app()->end();
			}


this is how this extension handle the exported result :lol:

thanks a lot, i view the source i fixed some problems in my code and it works.
HOPE IS A GOOD THING, MAYBE THE BEST THINGS, AND NO GOOD THING EVER DIES.
0

#4 User is offline   xiaoxiaoshijie 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 11-June 13

Posted 04 September 2013 - 03:28 AM

Please explain more, I am new bee and need some help to understand it.

View Postyiqing95, on 24 February 2013 - 06:23 AM, said:

read the source code ! this extension can both saving to a file and as a download file

	//create writer for saving
			$objWriter = PHPExcel_IOFactory::createWriter(self::$objPHPExcel, $this->exportType);
			if(!$this->stream)
				$objWriter->save($this->filename);
			else //output to browser
			{
				if(!$this->filename)
					$this->filename = $this->title;
				ob_end_clean();
				header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
				header('Pragma: public');
				header('Content-type: '.$this->mimeTypes[$this->exportType]['Content-type']);
				header('Content-Disposition: attachment; filename="'.$this->filename.'.'.$this->mimeTypes[$this->exportType]['extension'].'"');
				header('Cache-Control: max-age=0');
				$objWriter->save('php://output');
				die() ;  //Yii::app()->end();
			}


this is how this extension handle the exported result :lol:

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