1

Im a bit rusty using PHP and new to PHPexcel. I read all the realted posts of PHP Excel and still have no clue on how to solve my problem. The problem is that im reading an excel spreadsheet and showing it on HTML format. The problem is that the excel im reading has many columns and im only reading 6 of them., my code is this:

require_once 'PHPExcel/IOFactory.php';
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
    $highestRow         = $worksheet->getHighestRow();
    $highestColumn      = $worksheet->getHighestColumn();
    $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
    $columns = array('0', '5', '9', '13', '16', '20', '27');
    echo '<table border="1">';
    for ($row = 12; $row <= $highestRow; ++ $row) { 
        echo '<tr>';
        foreach ($columns as $column) {
            $cell = $worksheet->getCellByColumnAndRow($column, $row);
            $val = $cell->getValue();
            echo '<td>' . $val . '</td>';
        }
        echo '</tr>';
    }
    echo '</table>';
}

The problem is that when it reads from excel "09/13/2016" it shows on html as 42626. I know that its a format issue and PHPexcel is reading only the data and not the format, but cannot find out how to read only that col as date format., in the columns array, column 16, or position 4 in the array is the one that get date format. Can you help me achieve this, cause the second step is to load it into MYSQL ddbb., and i have all ready to do it., but need to figure this out.-

0 Answers0