I'm a beginner working on a web project and I've hit a bit of a wall. I have some data stored in an Excel file on my backend, like student records or product information, and I want to show that data on my frontend webpage, ideally in a pie chart format. What's the best way to go about doing this? Any suggestions would be appreciated!
2 Answers
Using an Excel file can be tricky. You might want to consider converting it to a CSV format, which is more straightforward and easier to handle. You can export your Excel data to CSV, then read it with JavaScript to display it on your site. Just keep in mind that I’m not sure exactly how you want the data presented, so this is a general idea!
Totally agree! CSV is the way to go. It's super easy to convert to JSON so you can loop through it and display it nicely on the front end!
While CSV is usually better, there are plenty of libraries for handling Excel files these days. If you're using JavaScript, libraries like `read-excel-file` might come in handy! Just remember to think about data validation too; you'll want to make sure the data is correct before displaying it.
I’d recommend writing a small script to convert your data to JSON, or if it's a minor task, you could even ask something like ChatGPT for help. Once you have it in JSON format, you can create a data.json file and import it into your frontend. This approach will also help you get used to working with JSON, as it's how you'll generally receive data from APIs. However, others have mentioned that a CSV parser can also do the trick pretty well!

For this project, teachers will upload student marks in Excel or CSV, and we need that data to show up on individual student login pages.