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
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.
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
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
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly