In this Excel Training video, we’re exploring a practical scenario where we demonstrate how to seamlessly save your Excel file as a CSV and then open it in a webpage using JQuery and JavaScript.
This powerful combination of technologies not only enhances the accessibility of your data but also opens up a world of possibilities for data presentation and interaction. So, join us as we guide you through the step-by-step process, from converting your Excel file into a CSV format to the seamless integration of JQuery and JavaScript to render the data on a webpage.
PSST, HEY, YOU
(YEAH, YOU!)
Want in on insightful videos, the latest tech developments, and epic exclusive content? Get all this and more as a member of our mailing list.
Resources
Link to the CSV Reader.
Copy the code:
<!DOCTYPE html>
<html>
<head>
<title>CSV Reader</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<h2>CSV Reader</h2>
<form id="csvForm" enctype="multipart/form-data">
<input type="file" id="csvFile" name="csvFile">
<br><br>
<button type="button" id="loadButton">Load</button>
<br><br>
</form>
<div id="resultTable"></div>
</body>
</html>
<script>
$(document).ready(function() {
$('#loadButton').click(function() {
var fileInput = $('#csvFile')[0];
var file = fileInput.files[0];
var reader = new FileReader();
reader.onload = function(e) {
var contents = e.target.result;
var rows = contents.split('\n');
var tableHtml = '<table border="1" cellpadding="10" cellspacing="0">';
rows.forEach(function(row) {
var data = row.split(',');
tableHtml += '<tr>';
data.forEach(function(cell) {
tableHtml += '<td>' + cell + '</td>';
});
tableHtml += '</tr>';
});
tableHtml += '</table>';
$('#resultTable').html(tableHtml);
};
reader.readAsText(file);
});
});
</script>