如果cell.index等于date.now,则phpexcel获取值

时间:2016-10-28 10:00:29

标签: php excel foreach phpexcel

我有一个带有shedule的excel文件。它看起来像这样: enter image description here

我需要获得当天的单元格值: john 8

我找到了示例,如何显示xls文件:

SqlDataReader userInfo = User.staffInfo("StaffCode, GroupIDs, Perms", User.getUsername());

string staffCode = userInfo["StaffCode"].ToString());

但我无法获得价值......

1 个答案:

答案 0 :(得分:0)

我改变了代码,所有工作都是:

$intN = 0;
foreach($aSheet->getRowIterator() as $row){
    $cellIterator = $row->getCellIterator();
    $cellIterator->setIterateOnlyExistingCells(true);
    // Iterate over the individual cells in the row
    foreach ($cellIterator as $cell) {
        $intN++;
        // Display information about the cell object
        if ($intN == $dateD){
            echo 'Cell ' , $cell->getCoordinate();
            echo '    is ' , $cell->getValue() , '<br />';
        }

    }
    $intN = 0;
}