forked from shuchkin/simplexlsx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimplexlsx.example3.php
More file actions
32 lines (26 loc) · 872 Bytes
/
simplexlsx.example3.php
File metadata and controls
32 lines (26 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
echo '<html><body><h1>XLSX to HTML</h1>';
if (isset($_FILES['file'])) {
require_once __DIR__ . '/simplexlsx.class.php';
if ( $xlsx = SimpleXLSX::parse( $_FILES['file']['tmp_name'] ) ) {
echo '<h2>Parsing Result</h2>';
echo '<table border="1" cellpadding="3" style="border-collapse: collapse">';
list( $cols, ) = $xlsx->dimension();
foreach ( $xlsx->rows() as $k => $r ) {
// if ($k == 0) continue; // skip first row
echo '<tr>';
for ( $i = 0; $i < $cols; $i ++ ) {
echo '<td>' . ( ( isset( $r[ $i ] ) ) ? $r[ $i ] : ' ' ) . '</td>';
}
echo '</tr>';
}
echo '</table>';
} else {
echo SimpleXLSX::parse_error();
}
}
echo '<h2>Upload form</h2>
<form method="post" enctype="multipart/form-data">
*.XLSX <input type="file" name="file" /> <input type="submit" value="Parse" />
</form>';
echo '</body></html>';