PHPExcel-如何按单元格值分组

时间:2018-11-01 14:11:03

标签: php sql phpexcel phpexcel-1.8.0

我想用PHPExcel列出值的下拉列表,但显示所有值并希望将它们分组,例如GROUP BY'CellValue' 我的代码是:

require_once "PHPExcel-1.8/Classes/PHPExcel.php";
    $tmpfname = "table.xlsx";
    $excelReader = PHPExcel_IOFactory::createReaderForFile($tmpfname);
    $excelObj = $excelReader->load($tmpfname);
    $worksheet = $excelObj->getSheet(0);
    $lastRow = $worksheet->getHighestRow();

    echo "<select name=''>";
    for ($row = 1; $row <= $lastRow; $row++) {
         echo "<option value=''>";
         echo $worksheet->getCell('C'.$row)->getValue();
         echo "</option>";
    }
    echo "</select>";   

0 个答案:

没有答案