I have implemented import text file, read the data and display on the screen, using the same code how can implement the Excel sheet import, read the data and display on the screen?
Code which I have tried for .txt file import :
HTML CODE
<form action="#" method="post" enctype="multipart/form-data">
<div>
<span>Choose file</span>
<span>
<input type="file" class="upload" name="file" style="width:260px;" >
</span>
</div>
<label class="fa-btn btn-1 btn-1e">
<input type="submit" name="submit" value="Upload Data">
</label>
</form>
PHP CODE
if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path)) {
echo "<p align=center style='color:green'><b>The file ". basename( $_FILES['file']['name'])." has been uploaded</p>";
$content = file_get_contents('upload/'.$_FILES["file"]["name"]);
$lines = explode("\n", $content); // TAKING NEW ROW BY ' \n '
}
foreach ($lines as $line) {
$row = explode(":", $line); //IN TEXT FILE COLUMN IS SEPARATED BY ' : '
?>
<tr style='background-color:lightgreen;'>
<td><?php echo $row[0]; ?></td>
<td><?php echo $row[1]; ?></td>
<td> <?php echo $row[2]; ?></td>
<td><?php echo $row[3]; ?></td>
<td><?php echo $row[4]; ?></td>
<td><?php echo $row[5]; ?></td>
}
Is it possible to display Excel data in the same way?
UPDATE
As suggested by @Mark Baker
working on this list