33 thoughts on “Convert Excel to JSON with Javascript

  1. 1. I used the same for creating in different project
    var roa = XLSX.utils.sheet_to_json(workbook.Sheets[sheetName], {header:1});

    if(roa.length) result[sheetName] = roa;
    But, This, I am getting an empty object.
    Any idea ?
    Also, I think, there is no need of localhost, Because, I am able to get the sheetname atleast.
    But the other data is not coming. from this….

    Also, If we run js-xlsx (index.html) as a separate application in tomcat webapps, That also gives the correct result.
    Please help.

  2. Hello @Red Stapler, I have a question.

    How can I display some of the JSON entries with arrays. For example, if the Phone column contains one the following cell: "iPhone 7, iPhone 8, iPhone X", I would like the JSON to look like this:

    Company: "Apple",
    Phone: [
    "iPhone 7",
    "iPhone 8",
    iPhone X",
    ],
    Price: 700

    Would this be possible? Thanks!

  3. Thanks brother. For everyone: if you want to display the excel content on the webpage, do this:
    in the script, type:
    var display = XLSX.utils.sheet_to_json(worksheet,{header:1});
    var x = document.getElementById('display').innerHTML = display;
    in the body, type:
    <p id="display"></p>
    You can loops in js and other stuff like table in html do display it differently. Good luck!

  4. I think Cross origin… errer cause because of you don't use local server
    Here is the example I tried with Vue.js
    https://gist.github.com/qkreltms/564332f2460a5899a7573b8d7510b0d2

  5. The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol. read.html
    [Show/hide message details.] Error: Unsupported file NaN
    i'm getting this error.. Please help

  6. when i am trying to use your solution I got this error :

    Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. Why you don't have it?

  7. That was amazing … exactly what I was looking for. Thank you so much. How I can send you suggestions for improvements?

  8. That's some quality content! My dad needs it in his work and thanks to this video I can easily help him. Thanks dude!

  9. THANKU VERY MUCH REALLY VERY GOOD VIDEO… I TIRED TO SEARCH FOR THIS CODE… BUT I FELL VERY HAPPY WHEN THIS WORKS BY SEEING YOUR VIDEO… THANKS A LOT
    AND PLEASE HELP ME I AM TRYING THIS FROM INPUT TYPE FILE HOW CAN I DO THIS FROM "INPUT TYPE="FILE";

  10. Nice one indeed. If I want to attach multiple sheets basically used for nesting. What do I need in that case. Will this thing work?

  11. wow thanks for the tutorial !! it helps me a lot, but i've a little more question, what if i've to get another sheet of the excel file? Thanks anyways !

Leave a Reply

Your email address will not be published. Required fields are marked *