Yii Framework Forum: [SOLVED] Import Excel to CGridView - Yii Framework Forum

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

[SOLVED] Import Excel to CGridView Rate Topic: -----

#1 User is offline   mhdrasad 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 199
  • Joined: 20-April 11
  • Location:Bumi Indonesia

Posted 27 June 2011 - 03:04 AM

Halooo master2 Yii...
Maap nih ganggu lagi. :D

Udah googling tapi kebanyakan bahas export excel :( .
1. Ada gak extension buat Import Excel di Yii ke CGridView.
2. Trus selain tampil di CGridView , itu data masuk juga ke databasenya. Gimana ya gan?.

Mohon pencerahannya... :D
Wait For True Concept or Finish it With Coding Concept .
#chadnox
0

#2 User is offline   rei 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 329
  • Joined: 10-November 10

Posted 27 June 2011 - 12:09 PM

Kalo ane lagi pake PHP-ExcelReader, gan.

Data yang di Excel diimpor ke database dulu, ntar tinggal di-load ke CGridView, gimana? :rolleyes:
Fipick - Find and pick recommendations
0

#3 User is offline   mhdrasad 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 199
  • Joined: 20-April 11
  • Location:Bumi Indonesia

Posted 27 June 2011 - 08:13 PM

View Postrei, on 27 June 2011 - 12:09 PM, said:

Kalo ane lagi pake PHP-ExcelReader, gan.

Data yang di Excel diimpor ke database dulu, ntar tinggal di-load ke CGridView, gimana? :rolleyes:


Sip gan, ane coba :D
Moga2 berhasil...
Wait For True Concept or Finish it With Coding Concept .
#chadnox
0

#4 User is offline   mhdrasad 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 199
  • Joined: 20-April 11
  • Location:Bumi Indonesia

Posted 27 June 2011 - 08:32 PM

agan rei, bisa kasih contohnya?.
Ane uda coba ngejalanin dari sample. Keluar pesan The filename example.xls is not readable .
Itu kenapa ya gan?. Mohon pencerahannya.
Wait For True Concept or Finish it With Coding Concept .
#chadnox
0

#5 User is offline   rei 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 329
  • Joined: 10-November 10

Posted 27 June 2011 - 09:57 PM

View Postputrilangit, on 27 June 2011 - 08:32 PM, said:

agan rei, bisa kasih contohnya?.
Ane uda coba ngejalanin dari sample. Keluar pesan The filename example.xls is not readable .
Itu kenapa ya gan?. Mohon pencerahannya.


File example.xls ada di mana, gan? Apa masih di folder extension-nya? Klo iya, coba pindahin ke direktori root dulu aja.

Contoh penggunaan:
Yii::import('ext.phpexcelreader.JPhpExcelReader');
$data = new JPhpExcelReader('xxx.xls');		
for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++)
{
  for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) 
  {
    $content = $data->sheets[0]['cells'][$i][$j];
    .....
  }
}

Fipick - Find and pick recommendations
0

#6 User is offline   mhdrasad 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 199
  • Joined: 20-April 11
  • Location:Bumi Indonesia

Posted 20 July 2011 - 02:13 AM

View Postrei, on 27 June 2011 - 09:57 PM, said:

File example.xls ada di mana, gan? Apa masih di folder extension-nya? Klo iya, coba pindahin ke direktori root dulu aja.

Aku nyimpen file xls nya disini gan.

E:\xampp\htdocs\Aplikasiku\protected\data\fileexcel.xls

baris ininya jadi gimana gan?
$data=new JPhpExcelReader('fileexcel.xls')

Wait For True Concept or Finish it With Coding Concept .
#chadnox
0

#7 User is offline   rei 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 329
  • Joined: 10-November 10

Posted 20 July 2011 - 06:04 AM

Mungkin begini:

$data = new JPhpExcelReader('protected/data/fileexcel.xls');


atau

$data = new JPhpExcelReader(Yii::app()->getBasePath(). '\data\fileexcel.xls');

Fipick - Find and pick recommendations
0

#8 User is offline   mhdrasad 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 199
  • Joined: 20-April 11
  • Location:Bumi Indonesia

Posted 21 July 2011 - 04:02 AM

View Postrei, on 20 July 2011 - 06:04 AM, said:

Mungkin begini:

$data = new JPhpExcelReader('protected/data/fileexcel.xls');


atau

$data = new JPhpExcelReader(Yii::app()->getBasePath(). '\data\fileexcel.xls');



tetep gan pesan errornya sama.
boleh minta gak yg agan buat itu kyk gimana?.
excel ke database. gpp gak ke cgridview jg, yang penting itu data di excel masuk database :D
Toloong share ya gan. :D
Wait For True Concept or Finish it With Coding Concept .
#chadnox
0

#9 User is offline   rei 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 329
  • Joined: 10-November 10

Posted 22 July 2011 - 01:17 AM

Wah, kenapa gak jalan, ya? Yang punya ane malah lebih simpel, kurang lebih cuma kaya gini:

$data = new JPhpExcelReader('import/cabinet.xls');


File excelnya versi berapa, gan? File 'example.xls' yang dikasih sama extensionnya bisa kebaca ga?

Atau coba cek hasil dari:
Yii::app()->getBasePath(). '\data\fileexcel.xls'


kalau betul harusnya jadi:
E:\xampp\htdocs\Aplikasiku\protected\data\fileexcel.xls

Fipick - Find and pick recommendations
0

#10 User is offline   mhdrasad 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 199
  • Joined: 20-April 11
  • Location:Bumi Indonesia

Posted 22 July 2011 - 02:46 AM

View Postrei, on 22 July 2011 - 01:17 AM, said:

File excelnya versi berapa, gan? File 'example.xls' yang dikasih sama extensionnya bisa kebaca ga?

Yang dari contoh juga gak jalan, keluar pesan error ini.
Function split() is deprecated

Office ku MS.Office 2007,
File contohnya gak aku apa2in kok, tetep gak jalan.
Wait For True Concept or Finish it With Coding Concept .
#chadnox
0

#11 User is offline   54byte 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 40
  • Joined: 06-November 10

Posted 23 July 2011 - 09:23 PM

View Postputrilangit, on 22 July 2011 - 02:46 AM, said:

Yang dari contoh juga gak jalan, keluar pesan error ini.
Function split() is deprecated

Office ku MS.Office 2007,
File contohnya gak aku apa2in kok, tetep gak jalan.

kalo ada error split()gtu, coba replace all semua keyword "split" jadi "explode" di library nya)(excel_reader2.php)gan..

btw saya kemarin coba2 extension ny dan gak tau kenapa error terus. Akhirnya saya pake library aslinya http://code.google.c...p-excel-reader/ dan langsung jalan dg mulus.
0

#12 User is offline   mhdrasad 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 199
  • Joined: 20-April 11
  • Location:Bumi Indonesia

Posted 24 July 2011 - 09:40 PM

View Post54byte, on 23 July 2011 - 09:23 PM, said:

kalo ada error split()gtu, coba replace all semua keyword "split" jadi "explode" di library nya)(excel_reader2.php)gan..

Sip gan, ud jalan...

View Post54byte, on 23 July 2011 - 09:23 PM, said:

btw saya kemarin coba2 extension ny dan gak tau kenapa error terus. Akhirnya saya pake library aslinya http://code.google.c...p-excel-reader/ dan langsung jalan dg mulus.

yang ini juga error tetep di split(), tapi ud jalan ketika di ganti explode. Tapi ane masih tetep gak ngerti sama errornya :D. Bantu jelasin donk gan.
Wait For True Concept or Finish it With Coding Concept .
#chadnox
0

#13 User is offline   54byte 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 40
  • Joined: 06-November 10

Posted 25 July 2011 - 01:59 AM

View Postputrilangit, on 24 July 2011 - 09:40 PM, said:

Sip gan, ud jalan...


yang ini juga error tetep di split(), tapi ud jalan ketika di ganti explode. Tapi ane masih tetep gak ngerti sama errornya :D. Bantu jelasin donk gan.


split() uda deprecated di PHP 5.3 gan http://au2.php.net/m...ction.split.php
0

#14 User is offline   mhdrasad 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 199
  • Joined: 20-April 11
  • Location:Bumi Indonesia

Posted 25 July 2011 - 03:51 AM

View Post54byte, on 25 July 2011 - 01:59 AM, said:

split() uda deprecated di PHP 5.3 gan http://au2.php.net/m...ction.split.php


Owh, gitu ya gan. :D Mantabz nih si agan.
klo ini kenapa gan?.
Deprecated: Assigning the return value of new by reference is deprecated in E:\xampp\htdocs\php-excel-reader\excel_reader2.php on line 916

915             function Spreadsheet_Excel_Reader($file='',$store_extended_info=true,$outputEncoding='') {
916		$this->_ole =& new OLERead();
917		$this->setUTFEncoder('iconv');
918		if ($outputEncoding != '') { 
919			$this->setOutputEncoding($outputEncoding);
910		}
	

Wait For True Concept or Finish it With Coding Concept .
#chadnox
0

#15 User is offline   54byte 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 40
  • Joined: 06-November 10

Posted 25 July 2011 - 06:39 AM

View Postputrilangit, on 25 July 2011 - 03:51 AM, said:

Owh, gitu ya gan. :D Mantabz nih si agan.
klo ini kenapa gan?.
Deprecated: Assigning the return value of new by reference is deprecated in E:\xampp\htdocs\php-excel-reader\excel_reader2.php on line 916

915             function Spreadsheet_Excel_Reader($file='',$store_extended_info=true,$outputEncoding='') {
916		$this->_ole =& new OLERead();
917		$this->setUTFEncoder('iconv');
918		if ($outputEncoding != '') { 
919			$this->setOutputEncoding($outputEncoding);
910		}
	



ganti code ini : $this->_ole =& new OLERead();
jadi begini gan : $this->_ole = new OLERead();
0

#16 User is offline   mhdrasad 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 199
  • Joined: 20-April 11
  • Location:Bumi Indonesia

Posted 26 July 2011 - 03:51 AM

View Post54byte, on 25 July 2011 - 06:39 AM, said:

ganti code ini : $this->_ole =& new OLERead();
jadi begini gan : $this->_ole = new OLERead();


Sip gan...berhasil.
ada lagi error ini gan.

Quote

include(PHPExcel_Shared_ZipStreamWrapper.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory

Nah ini knp gan?
Wait For True Concept or Finish it With Coding Concept .
#chadnox
0

#17 User is offline   54byte 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 40
  • Joined: 06-November 10

Posted 26 July 2011 - 02:46 PM

View Postputrilangit, on 26 July 2011 - 03:51 AM, said:

Sip gan...berhasil.
ada lagi error ini gan.

Nah ini knp gan?

wah, kalo itu ane ga tw jg gan.. coba googling aja..
0

#18 User is offline   mhdrasad 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 199
  • Joined: 20-April 11
  • Location:Bumi Indonesia

Posted 28 July 2011 - 04:57 AM

View Post54byte, on 26 July 2011 - 02:46 PM, said:

wah, kalo itu ane ga tw jg gan.. coba googling aja..


Udah ketemu ini gan, ane dapet dari sini.
Ternyata harus registrasi ulang.

http://www.yiiframew...brary-with-yii/

Alhamdulillah...berhasil juga
Wait For True Concept or Finish it With Coding Concept .
#chadnox
0

#19 User is offline   Firman 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 11-July 11

Posted 05 September 2011 - 01:03 AM

View Postputrilangit, on 28 July 2011 - 04:57 AM, said:

Udah ketemu ini gan, ane dapet dari sini.
Ternyata harus registrasi ulang.

http://www.yiiframew...brary-with-yii/

Alhamdulillah...berhasil juga


ane ada permasalahan seperti dibawah ini kenapa ya gan?
ane ikuti saran di http://www.yiiframew...brary-with-yii/
muncul ini
Fatal error: Class 'COutputProcessor' not found in D:\xampp\htdocs\yii-1.1.8.r3324\framework\web\widgets\CContentDecorator.php on line 33


ane hilangkan code:
spl_autoload_unregister(array('YiiBase','autoload')); 

muncul masalah mirip agan diatas :
include(PHPExcel_Shared_ZipStreamWrapper.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory

0

#20 User is offline   mhdrasad 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 199
  • Joined: 20-April 11
  • Location:Bumi Indonesia

Posted 06 September 2011 - 08:34 PM

View PostFirman, on 05 September 2011 - 01:03 AM, said:

ane ada permasalahan seperti dibawah ini kenapa ya gan?
ane ikuti saran di http://www.yiiframew...brary-with-yii/
muncul ini
Fatal error: Class 'COutputProcessor' not found in D:\xampp\htdocs\yii-1.1.8.r3324\framework\web\widgets\CContentDecorator.php on line 33


ane hilangkan code:
spl_autoload_unregister(array('YiiBase','autoload')); 

muncul masalah mirip agan diatas :
include(PHPExcel_Shared_ZipStreamWrapper.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory



Masalahnya cuma di autoloader aja gan. Yii dan PHPExcel punya autoloader. Dan klo Yii yang di panggil berarti autoload PHPExcel mati. Itu pesan error karena autoloader PHPExcel dalam posisi mati. Caranya adalah, pada saat proses exporting, matiin dulu punya yii <Unregister autoloadnya Yii> terus nyalain yang PHPExcel <Register autoload PHPExcelnya>.
Wait For True Concept or Finish it With Coding Concept .
#chadnox
0

Share this topic:


  • (2 Pages)
  • +
  • 1
  • 2
  • 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