abhi91tripathi / php-excel-reader

Automatically exported from code.google.com/p/php-excel-reader
0 stars 0 forks source link

raw() function not working properly #21

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. just try to read raw data. 
2.
3.

What is the expected output? What do you see instead?
I expected cell content. received empty values

Please provide any additional information below.
if I use ->val instead of ->raw i can read the data. The class opens the 
file and recognizes the number of rows and columns.

Original issue reported on code.google.com by mihai.gh...@gmail.com on 5 May 2009 at 4:01

GoogleCodeExporter commented 8 years ago
Ok. I managed to 'isolate' the issue. raw only returns something if the cells 
contain a number. so if it's text it doesn't return anything.

it would be nice to return the text if it's text and raw number if it's 
numeric. Now 
that I know I will make the changes in myscript to get the raw value only if 
it's 
numeric.

Original comment by mihai.gh...@gmail.com on 5 May 2009 at 5:11

GoogleCodeExporter commented 8 years ago
hi, I would like to ask if how do you temporarily solve the issue on the raw
function. Thanks

Original comment by theart20...@gmail.com on 19 May 2009 at 12:27

GoogleCodeExporter commented 8 years ago
I use ->val to get the values and then process the numbers to remove any 
formatting:

$number=Transforma($original_cell_value);

function my_is_numeric($value)  {
    if(preg_match ("/^(-){0,1}([0-9]+)(,[0-9][0-9][0-9])*([.][0-9]){0,1}([0-9]*)$/"
,$value)) return 1;
    else if (preg_match
("/^(-){0,1}([0-9]+)(.[0-9][0-9][0-9])*([,][0-9]){0,1}([0-9]*)$/" ,$value)) 
return 2;
   return 3;
}

function Transforma($x) {
$tip=$this->my_is_numeric($x);
if ($tip==1) $x=str_replace(',','',$x);
else if ($tip==2) {
        $x=str_replace('.','',$x);
        $x=str_replace(',','.',$x);
}
else $x=str_replace('"','""',$x);

return $x;
}

Original comment by mihai.gh...@gmail.com on 19 May 2009 at 6:15

GoogleCodeExporter commented 8 years ago
What I did was this... saves the trouble of parsing if you don't need to.

$val = $this->raw($row, $col, $sheet); // Assume we have a number.
if (!$val) $val = $this->val($row,$col,$sheet); //if not a number, get value. 

Original comment by min...@wi.rr.com on 20 May 2009 at 8:01

GoogleCodeExporter commented 8 years ago
hi, I used your function to remove a my formatting.but I cant get to manage to
eliminate the problem of negative values. Example in the cell the value is -300 
but
because it is formatted, when I retrieve it from the reader the reader still 
returns
(300). Any help? thanks you very much... 

Original comment by theart20...@gmail.com on 23 May 2009 at 12:36

GoogleCodeExporter commented 8 years ago
I guess you could look for enclosing brackets in the formatted string to 
identify a
negative number.

Original comment by mihai.gh...@gmail.com on 23 May 2009 at 7:12