Vendor/phpspreadsheet/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Writer/Html.php
public function generateSheetData()
    {
        // Spreadsheet object known?
        if ($this->spreadsheet === null) {
            throw new WriterException('Internal Spreadsheet object not set to an instance of an object.');
        }

        // Ensure that Spans have been calculated?
        if ($this->sheetIndex !== null || !$this->spansAreCalculated) {
            $this->calculateSpans();
        }

        // Fetch sheets
        $sheets = [];
        if ($this->sheetIndex === null) {
            $sheets = $this->spreadsheet->getAllSheets();
        } else {
            $sheets[] = $this->spreadsheet->getSheet($this->sheetIndex);
        }

        // Construct HTML
        $html = '';

        // Loop all sheets
        $sheetId = 0;
        foreach ($sheets as $sheet) {
            // Write table header
            $html .= $this->generateTableHeader($sheet);

            // Get worksheet dimension
            $dimension = explode(':', $sheet->calculateWorksheetDimension());
            $dimension[0] = Coordinate::coordinateFromString($dimension[0]);
            $dimension[0][0] = Coordinate::columnIndexFromString($dimension[0][0]);
            $dimension[1] = Coordinate::coordinateFromString($dimension[1]);
            $dimension[1][0] = Coordinate::columnIndexFromString($dimension[1][0]);

            // row min,max
            $rowMin = $dimension[0][1];
            $rowMax = $dimension[1][1];

            // calculate start of <tbody>, <thead>
            $tbodyStart = $rowMin;
            $theadStart = $theadEnd = 0; // default: no <thead>    no </thead>
            if ($sheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
                $rowsToRepeatAtTop = $sheet->getPageSetup()->getRowsToRepeatAtTop();

                // we can only support repeating rows that start at top row
                if ($rowsToRepeatAtTop[0] == 1) {
                    $theadStart = $rowsToRepeatAtTop[0];
                    $theadEnd = $rowsToRepeatAtTop[1];
                    $tbodyStart = $rowsToRepeatAtTop[1] + 1;
                }
            }

            // Loop through cells
            $row = $rowMin - 1;
            while ($row++ < $rowMax) {
                // <thead> ?
                if ($row == $theadStart) {
                    $html .= '        <thead>' . PHP_EOL;
                    $cellType = 'th';
                }

                // <tbody> ?
                if ($row == $tbodyStart) {
                    $html .= '        <tbody>' . PHP_EOL;
                    $cellType = 'td';
                }

                // Write row if there are HTML table cells in it
                if (!isset($this->isSpannedRow[$sheet->getParent()->getIndex($sheet)][$row])) {
                    // Start a new rowData
                    $rowData = [];
                    // Loop through columns
                    $column = $dimension[0][0];
                    while ($column <= $dimension[1][0]) {
                        // Cell exists?
                        if ($sheet->cellExistsByColumnAndRow($column, $row)) {
                            $rowData[$column] = Coordinate::stringFromColumnIndex($column) . $row;
                        } else {
                            $rowData[$column] = '';
                        }
                        ++$column;
                    }
                    $html .= $this->generateRow($sheet, $rowData, $row - 1, $cellType);
                }

                // </thead> ?
                if ($row == $theadEnd) {
                    $html .= '        </thead>' . PHP_EOL;
                }
            }
            $html .= $this->extendRowsForChartsAndImages($sheet, $row);

            // Close table body.
            $html .= '        </tbody>' . PHP_EOL;

            // Write table footer
            $html .= $this->generateTableFooter();

            // Writing PDF?
            if ($this->isPdf) {
                if ($this->sheetIndex === null && $sheetId + 1 < $this->spreadsheet->getSheetCount()) {
                    $html .= '<div style="page-break-before:always" />';
                }
            }

            // Next sheet
            ++$sheetId;
        }

        return $html;
    }
public function generateSheetData()
    {
        // Spreadsheet object known?
        if ($this->spreadsheet === null) {
            throw new WriterException('Internal Spreadsheet object not set to an instance of an object.');
        }

        // Ensure that Spans have been calculated?
        if ($this->sheetIndex !== null || !$this->spansAreCalculated) {
            $this->calculateSpans();
        }

        // Fetch sheets
        $sheets = [];
        if ($this->sheetIndex === null) {
            $sheets = $this->spreadsheet->getAllSheets();
        } else {
            $sheets[] = $this->spreadsheet->getSheet($this->sheetIndex);
        }

        // Construct HTML
        $html = '';

        // Loop all sheets
        $sheetId = 0;
        foreach ($sheets as $sheet) {
            // Write table header
            $html .= $this->generateTableHeader($sheet);

            // Get worksheet dimension
            $dimension = explode(':', $sheet->calculateWorksheetDimension());
            $dimension[0] = Coordinate::coordinateFromString($dimension[0]);
            $dimension[0][0] = Coordinate::columnIndexFromString($dimension[0][0]);
            $dimension[1] = Coordinate::coordinateFromString($dimension[1]);
            $dimension[1][0] = Coordinate::columnIndexFromString($dimension[1][0]);

            // row min,max
            $rowMin = $dimension[0][1];
            $rowMax = $dimension[1][1];

            // calculate start of <tbody>, <thead>
            $tbodyStart = $rowMin;
            $theadStart = $theadEnd = 0; // default: no <thead>    no </thead>
            if ($sheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
                $rowsToRepeatAtTop = $sheet->getPageSetup()->getRowsToRepeatAtTop();

                // we can only support repeating rows that start at top row
                if ($rowsToRepeatAtTop[0] == 1) {
                    $theadStart = $rowsToRepeatAtTop[0];
                    $theadEnd = $rowsToRepeatAtTop[1];
                    $tbodyStart = $rowsToRepeatAtTop[1] + 1;
                }
            }

            // Loop through cells
            $row = $rowMin - 1;
            while ($row++ < $rowMax) {
                // <thead> ?
                if ($row == $theadStart) {
                    $html .= '        <thead>' . PHP_EOL;
                    $cellType = 'th';
                }

                // <tbody> ?
                if ($row == $tbodyStart) {
                    $html .= '        <tbody>' . PHP_EOL;
                    $cellType = 'td';
                }

                // Write row if there are HTML table cells in it
                if (!isset($this->isSpannedRow[$sheet->getParent()->getIndex($sheet)][$row])) {
                    // Start a new rowData
                    $rowData = [];
                    // Loop through columns
                    $column = $dimension[0][0];
                    while ($column <= $dimension[1][0]) {
                        // Cell exists?
                        if ($sheet->cellExistsByColumnAndRow($column, $row)) {
                            $rowData[$column] = Coordinate::stringFromColumnIndex($column) . $row;
                        } else {
                            $rowData[$column] = '';
                        }
                        ++$column;
                    }
                    $html .= $this->generateRow($sheet, $rowData, $row - 1, $cellType);
                }

                // </thead> ?
                if ($row == $theadEnd) {
                    $html .= '        </thead>' . PHP_EOL;
                }
            }
            $html .= $this->extendRowsForChartsAndImages($sheet, $row);

            // Close table body.
            $html .= '        </tbody>' . PHP_EOL;

            // Write table footer
            $html .= $this->generateTableFooter();

            // Writing PDF?
            if ($this->isPdf) {
                if ($this->sheetIndex === null && $sheetId + 1 < $this->spreadsheet->getSheetCount()) {
                    $html .= '<div style="page-break-before:always" />';
                }
            }

            // Next sheet
            ++$sheetId;
        }

        return $html;
    }
public function generateSheetData ( ) { // Spreadsheet object known? if ( $ this -> spreadsheet === null ) { throw new WriterException ( 'Internal Spreadsheet object not set to an instance of an object.' ) ; } // Ensure that Spans have been calculated? if ( $ this -> sheetIndex !== null || ! $ this -> spansAreCalculated ) { $ this -> calculateSpans ( ) ; } // Fetch sheets $ sheets = [ ] ; if ( $ this -> sheetIndex === null ) { $ sheets = $ this -> spreadsheet -> getAllSheets ( ) ; } else { $ sheets [ ] = $ this -> spreadsheet -> getSheet ( $ this -> sheetIndex ) ; } // Construct HTML $ html = '' ; // Loop all sheets $ sheetId = 0 ; foreach ( $ sheets as $ sheet ) { // Write table header $ html .= $ this -> generateTableHeader ( $ sheet ) ; // Get worksheet dimension $ dimension = explode ( ':' , $ sheet -> calculateWorksheetDimension ( ) ) ; $ dimension [ 0 ] = Coordinate :: coordinateFromString ( $ dimension [ 0 ] ) ; $ dimension [ 0 ] [ 0 ] = Coordinate :: columnIndexFromString ( $ dimension [ 0 ] [ 0 ] ) ; $ dimension [ 1 ] = Coordinate :: coordinateFromString ( $ dimension [ 1 ] ) ; $ dimension [ 1 ] [ 0 ] = Coordinate :: columnIndexFromString ( $ dimension [ 1 ] [ 0 ] ) ; // row min,max $ rowMin = $ dimension [ 0 ] [ 1 ] ; $ rowMax = $ dimension [ 1 ] [ 1 ] ; // calculate start of <tbody>, <thead> $ tbodyStart = $ rowMin ; $ theadStart = $ theadEnd = 0 ; // default: no <thead>    no </thead> if ( $ sheet -> getPageSetup ( ) -> isRowsToRepeatAtTopSet ( ) ) { $ rowsToRepeatAtTop = $ sheet -> getPageSetup ( ) -> getRowsToRepeatAtTop ( ) ; // we can only support repeating rows that start at top row if ( $ rowsToRepeatAtTop [ 0 ] == 1 ) { $ theadStart = $ rowsToRepeatAtTop [ 0 ] ; $ theadEnd = $ rowsToRepeatAtTop [ 1 ] ; $ tbodyStart = $ rowsToRepeatAtTop [ 1 ] + 1 ; } } // Loop through cells $ row = $ rowMin - 1 ; while ( $ row ++ < $ rowMax ) { // <thead> ? if ( $ row == $ theadStart ) { $ html .= '        <thead>' . PHP_EOL ; $ cellType = 'th' ; } // <tbody> ? if ( $ row == $ tbodyStart ) { $ html .= '        <tbody>' . PHP_EOL ; $ cellType = 'td' ; } // Write row if there are HTML table cells in it if ( ! isset ( $ this -> isSpannedRow [ $ sheet -> getParent ( ) -> getIndex ( $ sheet ) ] [ $ row ] ) ) { // Start a new rowData $ rowData = [ ] ; // Loop through columns $ column = $ dimension [ 0 ] [ 0 ] ; while ( $ column <= $ dimension [ 1 ] [ 0 ] ) { // Cell exists? if ( $ sheet -> cellExistsByColumnAndRow ( $ column , $ row ) ) { $ rowData [ $ column ] = Coordinate :: stringFromColumnIndex ( $ column ) . $ row ; } else { $ rowData [ $ column ] = '' ; } ++ $ column ; } $ html .= $ this -> generateRow ( $ sheet , $ rowData , $ row - 1 , $ cellType ) ; } // </thead> ? if ( $ row == $ theadEnd ) { $ html .= '        </thead>' . PHP_EOL ; } } $ html .= $ this -> extendRowsForChartsAndImages ( $ sheet , $ row ) ; // Close table body. $ html .= '        </tbody>' . PHP_EOL ; // Write table footer $ html .= $ this -> generateTableFooter ( ) ; // Writing PDF? if ( $ this -> isPdf ) { if ( $ this -> sheetIndex === null && $ sheetId + 1 < $ this -> spreadsheet -> getSheetCount ( ) ) { $ html .= '<div style="page-break-before:always" />' ; } } // Next sheet ++ $ sheetId ; } return $ html ; }
Generate sheet data.

@throws WriterException

@return string
Generate sheet data .