Exemplo n.º 1
0
}
?>
<hr>

<h2>Date Handling</h2>
<p>Excel dates are returned as integers and need to be converted to Unix timestamps for ease of use in PHP.  
This examples takes the data in the 'Dates' sheet and modifies it to include columns for the Excel date,
the converted Unix Timestamp, the timestamp in ISO 8601 format, and the data from the second column in the sheet.</p>

<p>XLSXReader does not do automatic conversion of dates to Unix Timestamps, instead you must call the static function 
<code>XLSXReader::toUnixTimeStamp</code> on an Excel date (integer) to convert it.</p>


<?php 
$data = array_map(function ($row) {
    $converted = XLSXReader::toUnixTimeStamp($row[0]);
    return array($row[0], $converted, date('c', $converted), $row[1]);
}, $xlsx->getSheetData('Dates'));
array_unshift($data, array('Excel Date', 'Unix Timestamp', 'Formatted Date', 'Data'));
array2Table($data);
?>

</body>
</html>


<?php 
function array2Table($data)
{
    echo '<table>';
    foreach ($data as $row) {