Page 1 of 1

Spreadsheet Excel Reader Problem

Posted: Tue Jul 10, 2007 3:06 am
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??????? :(

Posted: Tue Jul 10, 2007 4:32 am
by jmut
Nobody knows what excel reader you're using.
Provide more info + snippets on how use are trying to do it.

Posted: Tue Jul 10, 2007 4:56 am
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: :?:

Posted: Tue Jul 10, 2007 4:58 am
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.

Posted: Tue Jul 10, 2007 5:00 am
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)

Spreadsheet_Excel_Reader

Posted: Fri Jul 27, 2007 5:54 pm
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');

Re: Spreadsheet Excel Reader Problem

Posted: Wed Jul 21, 2010 9:45 pm
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