PHP Excel Reader:获取删除/删除值

时间:2009-11-09 22:28:22

标签: php excel parsing

我正在寻找解析Excel工作表中单元格的删除/删除值的方法,尽可能使用PHP脚本。删除或不包含的单元格包含简单的文本值(无公式或任何内容)。

我尝试使用http://code.google.com/p/php-excel-reader/和其他一些脚本。但是我没有找到任何解析这个特定值(三角形)的PHP脚本,我尝试将这个解析功能添加到php-excel-reader中没有成功。

我尝试添加以下内容:

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

并且还为解析代码的这一部分添加了一些代码(用**表示):

            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;

但是我找不到表明删除值的正确数据。 v($ data,$ pos + 16)是不正确的,我尝试了很多其他的东西,没有任何成功。

如果用PHP库不可能,有什么想法我可以用Python或Perl脚本解析我的XLS,然后将数据切换到PHP?

似乎CPAN Perl脚本中的Spreadsheet :: ParseExcel-0.55可能有效但我的主应用程序是PHP所以我需要将结果写入文件并用PHP解析回来。

2 个答案:

答案 0 :(得分:1)

还可以查看:http://www.codeplex.com/PHPExcel

它说它可以读取Excel文件。我主要用它来写作,所以我不知道阅读的支持程度。

答案 1 :(得分:0)

使用PHPExcel(http://phpexcel.net,官方网址),您可以从单元格中读取样式值。对于删除线,就是这样的。

$cell->getStyle()->getFont()->getStrikethrough().