0

i need to read from excel file using php, the problem is these two lines:

require 'Classes/PHPExcel.php';
require_once 'Classes/PHPExcel/IOFactory.php';

//Rest of code  

Once I add these lines my code blocks , i'm sure the path is ok , i tried './Classes/PHPExcel etc..' doesn't work

When i execute it, it doesn't display anything , i often do echo 'smth', to see where it stops , but here only when i add these lines it stops, I use PHP 4.3 and PHPExcel 1.8

Can you guess where the error comes from ?

Skatox
  • 4,237
  • 12
  • 42
  • 47
  • `Can you guess where the error comes from ? ` NO! Check logs, enable errors, give us information; don't ask us to `guess`! – Mark Baker Mar 09 '14 at 14:10
  • Could you explain how your files are distributed? – Skatox Mar 09 '14 at 14:10
  • current folder contains : myfile.php and Classes folder which contains PHPExcel Folder the lines are on the file myfile.php – Safaa Jebari Mar 09 '14 at 14:11
  • But if you're using `PHP 4.3`, then you have major problems! – Mark Baker Mar 09 '14 at 14:12
  • And note that PHPExcel !== PHPExcelReader, they're to different libraries – Mark Baker Mar 09 '14 at 14:13
  • i use PHPExcel because i need to read xlsx files too , but i have to read only from xls file it will be ok can you tell me what are the appropriate libararies to use ? – Safaa Jebari Mar 09 '14 at 14:16
  • Nor do you need to require both 'Classes/PHPExcel.php' and 'Classes/PHPExcel/IOFactory.php'.... PHPExcel has an autoloader, you only need to include/require one or the other of those and the autoloader will include every other file that's needed – Mark Baker Mar 09 '14 at 14:17
  • There's nothing to stop you using PHPExcel, it's perfectly good for reading xlsx and xls files; but you need to do some basic debugging to identify why you can't include the library.... if you can't include a library like PHPExcel, you'll have problems with any other library as well – Mark Baker Mar 09 '14 at 14:18
  • Enable PHP errors, and check your error logs – Mark Baker Mar 09 '14 at 14:18
  • i did this : error_reporting(E_ALL ^ E_NOTICE); require 'Classes/PHPExcel.php'; it shows nothing – Safaa Jebari Mar 09 '14 at 14:24
  • Check error logs? If you're doing this through a web browser, check webserver logs! And PHPExcel requires a minimum PHP version of 5.2, it will not work with PHP 4.3!... why are you still using a version of PHP that's nearly 10 years out of date? – Mark Baker Mar 09 '14 at 14:30
  • Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in Classes/PHPExcel.php on line 50 – Safaa Jebari Mar 09 '14 at 14:33
  • for the moment i can't change this version, so i need a library that works with php 4.3 to load xls files, is there a way ? – Safaa Jebari Mar 09 '14 at 14:35
  • If you can't upgrade to a more recent version of PHP, you're going to have major problems of all kinds (security included)... but you might be able to find some old versions of spreadsheet_excel_reader in the pear archives that will work with PHP4... most libraries of any kind these days require PHP 5+ though – Mark Baker Mar 09 '14 at 14:42
  • Yes, i looked for the error and it says that it comes from the public/private attribute that make problems if running PHP4, but i cannot upgrade to PHP5 for the moment , i tried some PHPReader, all contains error , big problem... PHPExcel will defenitly NOT work with my php version – Safaa Jebari Mar 09 '14 at 14:45
  • Like I say, PHP 4.3 is 10-years old now, PHP has moved on into the 21st century, and most libraries for PHP assume that you will be using PHP5 these days - perhaps you should use that as an argument to force an upgrade to a more modern version of PHP – Mark Baker Mar 09 '14 at 14:47
  • i have other applications running on my server, if i ever upgrade the version , they might not work – Safaa Jebari Mar 09 '14 at 14:50
  • Perhaps if you got another server running PHP 5 for your newer applications, you could gradually transition the older applications over to PHP5... but you can't rely on any new libraries working with PHP4 these days – Mark Baker Mar 09 '14 at 14:59

2 Answers2

0

If they're not loading, your file paths are incorrect. Simple as that.

  1. Verify your file structure current folder/root folder that has myfile.php, inside does it have a folder called Classes? or... did you forget to include /phpexcel/Classes/ ?

default installation (if you followed the instructions)

require 'phpexcel/Classes/PHPExcel.php';
require_once 'phpexcel/Classes/PHPExcel/IOFactory.php';
  1. Add debug code You can add echo statements in the PHPExcel libraries to see if they are really loading... if they're not... consult step 1.

  2. Try using an earlier version of PHP To test you can easily download XAMPP or WAMP to setup a local web host and test it out.

JCastell
  • 1,135
  • 1
  • 10
  • 11
0

I resolved the problem by using PHP EXCEL Reader because i use php 4 wich wont work with this library or with .xlsx files. now it is done , and my sheet was read , still , only one sheet is read. Thank you All !