0
votes

How to add rowspan/colspan from phpexcel view table in html ?

I have this table.

A2 cell merged with A1

I want to view that excel in html using PHPexcel View but what i got is just like,

Not merge

The first column was not merged with the second column.

Does anyone know how to add rowspan in phpexcel view in html ?

My code is just like this

 $tmpfname = "./sampleData/member.xls";

    $excelObj = $excelReader->load($tmpfname);
    $worksheet = $excelObj->getActiveSheet();
    $worksheet->mergeCells('A1:A3');
    $cell = $worksheet->getCell('A1');
    $lastRow = $worksheet->getHighestRow();


    echo '<table border="1"  >';
    for ($row = 1; $row <= $lastRow; $row++) {

         echo "<tr><td>";
         echo $worksheet->getCell('A'.$row)->getValue();
         echo "</td><td>";
         echo $worksheet->getCell('B'.$row)->getValue();
         echo "</td><td>";
          echo $worksheet->getCell('C'.$row)->getValue();
         echo "</td><td>";
         echo $worksheet->getCell('D'.$row)->getValue();
         echo "</td><td>";
         echo $worksheet->getCell('E'.$row)->getValue();
         echo "</td><td>";
         echo $worksheet->getCell('F'.$row)->getValue();
         echo "</td><td>";
         echo $worksheet->getCell('G'.$row)->getValue();
         echo "</td><td>";
         echo $worksheet->getCell('J'.$row)->getValue();
         echo "</td><td>";
         echo $worksheet->getCell('K'.$row)->getValue();
         echo "</td><td>";
         echo $worksheet->getCell('L'.$row)->getValue();
         echo "</td><td>";
         echo $worksheet->getCell('M'.$row)->getValue();
         echo "</td><td>";
         echo $worksheet->getCell('N'.$row)->getValue();
         echo "</td><td>";
         echo $worksheet->getCell('O'.$row)->getValue();
         echo "</td><tr>";
    }
    echo "</table>";    
1

1 Answers

1
votes

Probably you can use createWriter for creating HTML table from phpExcelObject.

$objWriter = $this->get('phpexcel')->createWriter($phpExcelObject, 'HTML');
ob_start();
$objWriter->save('php://output');
$excelOutput = ob_get_clean();

echo $excelOutput;