I am allowing user to allow uploading xlsx file, performing transliteration (arabic to english) and displaying on web page as a table content. (same view as xlsx file).
- Can I export table content to xlsx? (cell content should persist their cell position)
- Or is it possible to write each processes cell result to xlsx?
Here is the code:
if (isset($_FILES['file'])) {
header('Content-Type: text/html; charset=UTF-8');
require_once "simplexlsx.class.php";
require '../../Arabic.php';
$Arabic = new I18N_Arabic('Transliteration');
$xlsx = new SimpleXLSX( $_FILES['file']['tmp_name'] );
echo '<h1>Parsing Result</h1>';
echo '<table border="1" cellpadding="3" style="border-collapse: collapse">';
$eng = array();
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++)
{
$temp = $Arabic->ar2en($r[$i]);
echo '<td>'.( (isset($r[$i])) ? $temp : ' ' ).'</td>';
}
echo '</tr>';
}
echo '</table>';
}
?>
<h1>Upload</h1>
<form method="post" enctype="multipart/form-data">
*.XLSX <input type="file" name="file" /> <input type="submit" value="Parse" />
</form>