tags:

views:

318

answers:

2

I am looking for way to parse the strikeout / strikethrough value of cells in an Excel sheet, using if possible a PHP script. The cells that are strikeout or not contain simple text values (no formula or anything).

I have try using http://code.google.com/p/php-excel-reader/ and a few others scripts. But I have not found any PHP script that parse this specific value (strikeout) and I have try without success to add this parsing feature to the php-excel-reader.

I have try to add the following :

function lineTrought($row,$col,$sheet=0) {
 return $this->fontProperty($row,$col,$sheet,'strikethrough');
}

And also add some code to this part of the parse code (indicated by **) :

   case SPREADSHEET_EXCEL_READER_TYPE_FONT:
     $height = v($data,$pos+4);
     $option = v($data,$pos+6);
     $color = v($data,$pos+8);
     $weight = v($data,$pos+10);
     $under  = ord($data[$pos+14]);
     **$strikethrough  = v($data,$pos+16);**
     $font = "";
     // Font name
     $numchars = ord($data[$pos+18]);
     if ((ord($data[$pos+19]) & 1) == 0){
         $font = substr($data, $pos+20, $numchars);
     } else {
         $font = substr($data, $pos+20, $numchars*2);
         $font =  $this->_encodeUTF16($font); 
     }
     $this->fontRecords[] = array(
       'height' => $height / 20,
       'italic' => !!($option & 2),
       'color' => $color,
       'under' => !($under==0),
       'bold' => ($weight==700),
       **'strikethrough'=>$strikethrough,**
       'font' => $font,
       'raw' => $this->dumpHexData($data, $pos+3, $length)
       );
        break;

But I can't find the right data that indicate the strikethrough value. v($data,$pos+16) is incorrect and I have try a bunch of other stuff without any success.

If not possible with a PHP library, any idea on how I could parse my XLS with a Python or Perl script and then switch the data to PHP?

It seems like Spreadsheet::ParseExcel-0.55 from CPAN Perl script might work but my main application is PHP so I would need to write result to a file and parse it back in PHP or something like this.

A: 

I cannot test this. What does

$data->style($row,$col,$sheet=0)

return for a cell with strikeout text?

Sinan Ünür
A: 

hi,

also check out: http://www.codeplex.com/PHPExcel

it says it could read Excel files. i was using it mostly for writing, so I don't know to what extent reading is supported.

dusoft
Seems to be a very complete library, I'll try it. I do not understand how I did not found this one. Me fail.
jpdoyle