Read Excel file on page load from url and show contents


My question is regarding this article "Read Excel file using Javascript". It is very useful script and I was searching it from long time.

Basically, I want to open address.xlsx automatically and read it, when I open html file in browser, don't want to browse file and then read/show the Excel output. How can I do it.

If possible, I would like to add, an input text-box with ability of search excel data displayed table.

Thanks


Asked by:- manjoo
0
: 6353 At:- 10/19/2020 12:38:14 PM
Javascript read excel javascript







3 Answers
profileImage Answered by:- vikas_jk

As you have not mentioned any code or what you have done until now, I can suggest you following steps:

1.On page load, fetch excel file URL and convert it into blob using JavaScript, refer https://stackoverflow.com/questions/44070437/how-to-get-a-file-or-blob-from-an-url-in-javascript

2.From Blob convert to binarystring https://stackoverflow.com/questions/27208407/convert-blob-to-binary-string-synchronously

3. Once you have got the Binary string, you can pass this value in FileReader and then call GetTableFromExcel(Data) from above linked page method.

 var reader = new FileReader();

 reader.onload = function (e) {
                        GetTableFromExcel(e.target.result);
                    };
 reader.readAsBinaryString(yourBinaryString);

That's it.

Regarding search on table, once data is loaded is table, use jQuery datatable, it will automatically add searching and sorting in table.

 

0
At:- 10/20/2020 7:46:55 AM


profileImage Answered by:- manjoo

Thanks for your reply here is code wherein i have to select/load excel file, I want to load file automatically on page load

<input id="x_x_upload" type="button" value="Upload">
<input id="x_x_fileUpload" type="file">

I want to load file:///D:/Addresses/address.xlxs files

0
At:- 10/20/2020 9:17:10 AM


profileImage Answered by:- vikas_jk

It is not possible to set input type file value on page load

You cannot set a value to an input[type=file] element, because its very dangerous for a user. If the browser allow to do this then everyone will be able to get the files from the system of the user of a website, which is totally irrelevant for a user's privacy.

You can refer it here https://stackoverflow.com/a/48162777/3559462

Thanks

0
At:- 10/21/2020 11:31:23 AM






Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use