public function parse()
    {
        if (null === $this->html) {
            throw new HtmlPhpExcelException('You must provide html content first. Use setHtml() or setHtmlFile().');
        }

        $dom = new \DOMDocument();
        $dom->loadHTML($this->html);

        $xpath = new \DOMXPath($dom);
        $htmlTables = $xpath->query('.//table[contains(concat(" ", normalize-space(@class), " "), "'.$this->tableClass.'")]');

        $document = new Document();

        foreach ($htmlTables as $htmlTable) {

            $table = new Table();

            $htmlRows = $xpath->query('.//tr[contains(concat(" ", normalize-space(@class), " "), "'.$this->rowClass.'")]', $htmlTable);
            foreach($htmlRows as $htmlRow) {

                $row = new Row();
                $htmlCells = $xpath->query(
                     './/td[contains(concat(" ", normalize-space(@class), " "), "'.$this->cellClass.'")]
                    | .//th[contains(concat(" ", normalize-space(@class), " "), "'.$this->cellClass.'")]',
                    $htmlRow
                );

                foreach($htmlCells as $htmlCell) {
                    $cell = new Cell();
                    $cell->setValue($htmlCell->nodeValue);

                    foreach ($htmlCell->attributes as $attribute) {
                        $cell->addAttribute($attribute->name, $attribute->value);
                    }

                    if ('th' == $htmlCell->nodeName) {
                        $cell->setIsHeader(true);
                    }

                    $row->addCell($cell);
                }

                foreach ($htmlRow->attributes as $attribute) {
                    $row->addAttribute($attribute->name, $attribute->value);
                }

                $table->addRow($row);
            }

            foreach ($htmlTable->attributes as $attribute) {
                $table->addAttribute($attribute->name, $attribute->value);
            }

            $document->addTable($table);
        }

        return $document;
    }
public function parse()
    {
        if (null === $this->html) {
            throw new HtmlPhpExcelException('You must provide html content first. Use setHtml() or setHtmlFile().');
        }

        $dom = new \DOMDocument();
        $dom->loadHTML($this->html);

        $xpath = new \DOMXPath($dom);
        $htmlTables = $xpath->query('.//table[contains(concat(" ", normalize-space(@class), " "), "'.$this->tableClass.'")]');

        $document = new Document();

        foreach ($htmlTables as $htmlTable) {

            $table = new Table();

            $htmlRows = $xpath->query('.//tr[contains(concat(" ", normalize-space(@class), " "), "'.$this->rowClass.'")]', $htmlTable);
            foreach($htmlRows as $htmlRow) {

                $row = new Row();
                $htmlCells = $xpath->query(
                     './/td[contains(concat(" ", normalize-space(@class), " "), "'.$this->cellClass.'")]
                    | .//th[contains(concat(" ", normalize-space(@class), " "), "'.$this->cellClass.'")]',
                    $htmlRow
                );

                foreach($htmlCells as $htmlCell) {
                    $cell = new Cell();
                    $cell->setValue($htmlCell->nodeValue);

                    foreach ($htmlCell->attributes as $attribute) {
                        $cell->addAttribute($attribute->name, $attribute->value);
                    }

                    if ('th' == $htmlCell->nodeName) {
                        $cell->setIsHeader(true);
                    }

                    $row->addCell($cell);
                }

                foreach ($htmlRow->attributes as $attribute) {
                    $row->addAttribute($attribute->name, $attribute->value);
                }

                $table->addRow($row);
            }

            foreach ($htmlTable->attributes as $attribute) {
                $table->addAttribute($attribute->name, $attribute->value);
            }

            $document->addTable($table);
        }

        return $document;
    }
public function parse ( ) { if ( null === $ this -> html ) { throw new HtmlPhpExcelException ( 'You must provide html content first. Use setHtml() or setHtmlFile().' ) ; } $ dom = new \ DOMDocument ( ) ; $ dom -> loadHTML ( $ this -> html ) ; $ xpath = new \ DOMXPath ( $ dom ) ; $ htmlTables = $ xpath -> query ( './/table[contains(concat(" ", normalize-space(@class), " "), "' . $ this -> tableClass . '")]' ) ; $ document = new Document ( ) ; foreach ( $ htmlTables as $ htmlTable ) { $ table = new Table ( ) ; $ htmlRows = $ xpath -> query ( './/tr[contains(concat(" ", normalize-space(@class), " "), "' . $ this -> rowClass . '")]' , $ htmlTable ) ; foreach ( $ htmlRows as $ htmlRow ) { $ row = new Row ( ) ; $ htmlCells = $ xpath -> query ( './/td[contains(concat(" ", normalize-space(@class), " "), "' . $ this -> cellClass . '")]
                    | .//th[contains(concat(" ", normalize-space(@class), " "), "' . $ this -> cellClass . '")]' , $ htmlRow ) ; foreach ( $ htmlCells as $ htmlCell ) { $ cell = new Cell ( ) ; $ cell -> setValue ( $ htmlCell -> nodeValue ) ; foreach ( $ htmlCell -> attributes as $ attribute ) { $ cell -> addAttribute ( $ attribute -> name , $ attribute -> value ) ; } if ( 'th' == $ htmlCell -> nodeName ) { $ cell -> setIsHeader ( true ) ; } $ row -> addCell ( $ cell ) ; } foreach ( $ htmlRow -> attributes as $ attribute ) { $ row -> addAttribute ( $ attribute -> name , $ attribute -> value ) ; } $ table -> addRow ( $ row ) ; } foreach ( $ htmlTable -> attributes as $ attribute ) { $ table -> addAttribute ( $ attribute -> name , $ attribute -> value ) ; } $ document -> addTable ( $ table ) ; } return $ document ; }
Parses the html code

@return \Ticketpark\HtmlPhpExcel\Elements\Document
Parses the html code