marcovtwout / yii-phpexcel

Yii wrapper for PHPExcel
24 stars 11 forks source link

on ->load() #3

Closed llechevbulpont closed 10 years ago

llechevbulpont commented 10 years ago

When using init() and after that load some file it gives me error: include(PHPExcel_Style_Supervisor.php) [function.include]: failed to open stream: No such file or directory

Is this from the extension or something else?

marcovtwout commented 10 years ago

Which version of PHPExcel are you using? Could you post a complete code example?

llechevbulpont commented 10 years ago

Thank you for your fast Reply, I managed to get it fixed! The solution: You need to make new instance of the PHPExcel, no matter if you're going to use it or not. I didn't need it because I had to Read from file. Please write this at the Documentation.

If people wont use PHPExcel class Directly they need to call createPHPExcel =) AND the init() has to return PHPExcel for this to work =)

marcovtwout commented 10 years ago

Strange. Can you check if creating a new PHPExcel instance loads your required class in some way? I've added it to the Readme.

llechevbulpont commented 10 years ago

I used clean PHPExcel to try if it was from your wrapper. I end up at the same error. After 4-5 hours I made new Instance: "new PHPExcel();" and it fired the Autoloader which loaded the classes.

marcovtwout commented 10 years ago

Could you post your example code?

llechevbulpont commented 10 years ago
$phpExcel = new PHPExcel();
$objReader = PHPExcel_IOFactory::createReader('Excel2007'); // the reader version to use
$objReader->setReadDataOnly(TRUE); // read data only

$objPHPExcel = $objReader->load($model->file_import->getTempName()); // load uploaded file
$objWorksheet = $objPHPExcel->getActiveSheet(); // get active sheet

$highestRow = $objWorksheet->getHighestDataRow(); // e.g. 10 getHighestRowAndColumn
$highestColumn = $objWorksheet->getHighestColumn(); // e.g 'F'

$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); // e.g. 5
...
$objWorksheet->getCellByColumnAndRow($col, $row)->getFormattedValue();
...

Hope this is usefull!

marcovtwout commented 10 years ago

When you replace the first line with:

Yii::import('ext.phpexcel.XPHPExcel');      
$phpExcel = XPHPExcel::createPHPExcel();

What error message do you get, and in which line?