How to Export Excel Data to a Web Page

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.

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>

John Gleave

John Gleave has been a researcher, content writer, and senior editor at Business Tech Planet since 2022. John was formerly a data analyst and web designer with expertise in several programming languages, such as JavaScript, JQuery, PHP, CSS, SQL, and more! With a passion for writing and technology, he has now focused his skills on crafting tech guides for BTP. You can connect with John on LinkedIn.

Recent Posts