1

I'm building web page that can read any Excel file with any number of sheets, print them in table, and then store them in PhpMyAdmin database.

I need to know if there is any function to count number of sheets and read them one by one to store their names as new tables and store their values in PhpMyAdmin database.

<div id="navbar"><span>Excel File - SheetJS</span></div>
<div id="wrapper">
  <input type="file" id="input-excel" />
</div>
$('#input-excel').change(function(e) {
  var reader = new FileReader();
  reader.readAsArrayBuffer(e.target.files[0]);
  reader.onload = function(e) {
    var data = new Uint8Array(reader.result);
    var wb = XLSX.read(data,{type:'array'});
    var htmlstr = XLSX.write(wb,{sheet:"sheet no1",  type:'binary',bookType:'html'});
    $('#wrapper')[0].innerHTML += htmlstr;
  }
});

This code will read only the first sheet.
I'm only in the beginning. I just want to make sure that all the data in all sheets will be printed. After that I will move to next step to store them in database.

I didn't use anything rather than JavaScript and HTML.

Azametzin
  • 5,223
  • 12
  • 28
  • 46
Sarah
  • 11
  • 3
  • Possible duplicate of [How to parse Excel file in Javascript/HTML5](https://stackoverflow.com/questions/8238407/how-to-parse-excel-file-in-javascript-html5) – Slai May 20 '19 at 10:41
  • Terminology note: PhpMyAdmin is not a database. It's just an application which allows you to interact with a mySQL database. There are many other such applications. Your database engine is mySQL. – ADyson May 20 '19 at 10:46
  • Anyway if you are wanting to store this data in a database, you cannot do it from JavaScript, because JavaScript running in a browser cannot connect directly to the database. Instead, you will need to make the user submit a form, which will upload the file to your server, and then you can use some server side code (e.g. something written in PHP, NodeJS, asp.net, Java or whatever you prefer) to read the uploaded file, process it and insert the data into the database. – ADyson May 20 '19 at 10:48
  • Thank you my dear friends. Honestly, I was having some doubts about whether PhpMyAdmin is a database or not , but thank you for the clarification! Now I would love to know if there are any useful resources where I can find the functions for counting and reading multiple sheets in one excel file? I just want to print data for now and after that, I will store it in the database using Php. – Sarah May 20 '19 at 11:16
  • What have you searched for so far? Google "PHP read excel file" and I'm pretty sure you will find lots of information. We don't do recommendations of external resources here, nor do we do research on your behalf. We will help you fix a problem in your code though, if you've got one – ADyson May 20 '19 at 11:27
  • I've searched before I ask for assistance + I don't want anyone to do research on my behalf! I just wanted to know if there is anyone who has experience and knowledge more than me in this case where I can get recommendations for useful resources so I can continue searching in them. That's all that I've asked for. Anyway.. thanks for your suggestion. – Sarah May 27 '19 at 22:25

0 Answers0