Spreadsheet Excel Reader Problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
the_last_tamurai
Forum Commoner
Posts: 87
Joined: Wed Feb 28, 2007 8:24 am
Location: cairo
Contact:

Spreadsheet Excel Reader Problem

Post by the_last_tamurai »

Hi everyone,
I've a problem with the excel reader class (Spreadsheet Excel Reader), When I start to read from the excel sheet I get all cell prefixed by (?) and last character deleted, but when I just open the excel and save (even with no editing ) it parse the file correctly.

Any suggestions??????? :(
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

Nobody knows what excel reader you're using.
Provide more info + snippets on how use are trying to do it.
User avatar
the_last_tamurai
Forum Commoner
Posts: 87
Joined: Wed Feb 28, 2007 8:24 am
Location: cairo
Contact:

Post by the_last_tamurai »

I think I gave its name , ok :) , again it's Spreadsheet_Excel_Reader Class

Code: Select all

// create ExcelReader object
$xl_reader = new Spreadsheet_Excel_Reader();
$xl_reader->read('file.xls');
    			
// calculate number of rows and columns
$rows = $xl_reader->sheets[0]['numRows'];
$cols = $xl_reader->sheets[0]['numCols'];
for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
  for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++) {
echo "[$i,$j] \t";
echo $data->sheets[0]['cells'][$i][$j];
}
echo "<br>";
}
it gives me the data like this : If the cell contains 'Hello tamer' it gives '?Hello tame'

:roll: :?:
Last edited by the_last_tamurai on Tue Jul 10, 2007 4:59 am, edited 1 time in total.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

well seems to be some buggy class.
Sorry but just naming the class does not give any info from where this class is?!?!
Where did you get it from?
.....
Anyhow...seems like bug into class..should dig deeper.
User avatar
the_last_tamurai
Forum Commoner
Posts: 87
Joined: Wed Feb 28, 2007 8:24 am
Location: cairo
Contact:

Post by the_last_tamurai »

I edit my last post with the link
I'ne to say that the sheet contains some non-English words... but I overcome it with the encoding

Edit : I try now to apply Spreadsheet_Excel_Writer

but seems like it just add new workbook but no editing (All I want just to edit one empty cell and save the .xls file (existing one ) by the script ,to overcome this bug)
norms
Forum Newbie
Posts: 1
Joined: Fri Jul 27, 2007 5:49 pm

Spreadsheet_Excel_Reader

Post by norms »

Try setting the output coding :idea:

$xl_reader = new Spreadsheet_Excel_Reader();
$xl_reader->setOutputEncoding('CP1251'); // select output encoding
$xl_reader->read('file.xls');
James23
Forum Newbie
Posts: 1
Joined: Wed Jul 21, 2010 9:40 pm

Re: Spreadsheet Excel Reader Problem

Post by James23 »

HEY,
There is a nice tool for reading Microsoft Excel files called PHPExcelReader. It works with .xls files up to Excel version 2003, which are based on the BIFF format (later versions use OOXML). It is written in native PHP and does not require any third-party libraries or the MS Office package.

Looping through all cells in a sheet with PHPExcelReader is as simple as this:

require_once 'Excel/reader.php';

$reader = new Spreadsheet_Excel_Reader();
$reader->setOutputEncoding("UTF-8");

$reader->read("test.xls");

for ($i = 1; $i <= $reader->sheets[0]["numRows"]; $i++)
{
for ($j = 1; $j <= $reader->sheets[0]["numCols"]; $j++)
{
print "\"".$reader->sheets[0]["cells"][$i][$j]."\",";
}
echo "\n";
}


make money online
Post Reply