使用php中的Spreadsheet_Excel_Reader从excel文件中读取URL

时间:2016-04-13 12:22:22

标签: php excel

我正在使用Spreadsheet_Excel_Reader()来读取excel文件。

我想在下面的表格数据中读取网址

<a href="link">text</a>

我知道这个问题可以通过像这样使用PHPExcel来解决

$leadCommentLInk=$worksheet->getCellByColumnAndRow(7, 2)->getHyperlink()->getUrl();

请帮助我

1 个答案:

答案 0 :(得分:0)

最后,通过更改我的reader.php文件,我得到了解决方案

在_parsesheet方法

中添加了以下切换案例
gameBoardViewController

并添加此常量

case SPREADSHEET_EXCEL_READER_TYPE_HYPER:
                //  Only handle hyperlinks to a URL
                $row    = ord($this->data[$spos]) | ord($this->data[$spos+1])<<8;
                $row2   = ord($this->data[$spos+2]) | ord($this->data[$spos+3])<<8;
                $column = ord($this->data[$spos+4]) | ord($this->data[$spos+5])<<8;
                $column2 = ord($this->data[$spos+6]) | ord($this->data[$spos+7])<<8;
                $linkdata = Array();
                $flags = ord($this->data[$spos + 28]);
                $udesc = "";
                $ulink = "";
                $uloc = 32;
                $linkdata['flags'] = $flags;
                if (($flags & 1) > 0 ) {   // is a type we understand
                    //  is there a description ?
                    if (($flags & 0x14) == 0x14 ) {   // has a description
                        $uloc += 4;
                        $descLen = ord($this->data[$spos + 32]) | ord($this->data[$spos + 33]) << 8;
                        $udesc = substr($this->data, $spos + $uloc, $descLen * 2);
                        $uloc += 2 * $descLen;
                    }
                    $ulink = $this->read16bitstring($this->data, $spos + $uloc + 20);
                    if ($udesc == "") {
                        $udesc = $ulink;
                    }
                }
                $linkdata['desc'] = $udesc;
                $linkdata['link'] = $this->_encodeUTF16($ulink);
                for ($r=$row; $r<=$row2; $r++) { 
                    for ($c=$column; $c<=$column2; $c++) {
                        $this->sheets[$this->sn]['cellsInfo'][$r+1][$c+1]['hyperlink'] = $linkdata;
                    }
                }
                break;

和mothod

define('SPREADSHEET_EXCEL_READER_TYPE_HYPER',        0x01b8);

或者我们只需使用一个文件excel_reader2.php