How to read an xlsx file with javascript

10,098

Excel has no API that JavaScript can access client-side. To the contrary, using VBA you can extract data from the spreadsheet and then open a web browser and write JavaScript into the document that the browser is showing.

To do what you want, you'd need to access the Excel data on the server, via some server-side API (probably .NET) and then deliver that data to the client as HTML, CSS and JavaScript.

FYI: That example you referenced is a server-side solution using node.

Share:
10,098
skyzzle
Author by

skyzzle

Updated on June 04, 2022

Comments

  • skyzzle
    skyzzle almost 2 years

    So I have been googling and googling and googling this for the past few hours and every thing I have tried dose not work.

    all I want to do is read the values in the cells (using the field name and index number) of an excel spreadsheet using javascript and then display the data that is in the cells as strings on an webpage.

    evey time i google this it eyther sends me to here http://codetheory.in/parse-read-excel-files-xls-xlsx-javascript which I can't get to work and I do not think it is what I want anyway as it looks like its just creating other files to use.

    or it takes me to other posts here on stack overflow that either do not answer my question (for example they have converters where you drag and drop an xlsx file in to an converter to convert it to CSV or JSON which will not work because it has to be automated) or they have links that link to other posts that lead me to something that was irreverent.

    EDIT----- To make it clear I am only to build a webpage that displays the content that is in the xslx. The xslx file will be replaced every day.

    I have no control over what goes on the server other then what is in the folder that holds the webpage and xslx file.

    the process has to be compleatley automated (with the exception of uploading the xslx file that just a copy and paste thing)

  • skyzzle
    skyzzle over 7 years
    Cant be server side. I am unable to touch that at all. I have to make an javascript file to read the context of the xlsx file and display it in an html page. that it. just a single folder with every thing in it running that will be copped over to the server. every day the xslx file will be changed. the clients will load the webpage. that it. no instilling anything just copying over files.
  • Scott Marcus
    Scott Marcus over 7 years
    What you are trying to do is not going to be possible. Now, if the Excel file were to be exported to a text-based file (like a .csv) you could make an AJAX call for that data and consume it, But not an .xslx. See: this for details: stackoverflow.com/questions/6382572/…