4

I have one html which display data in table format by reading XLS file.This page giving two option to user. first is to ask user to upload xls file and second is to user already uploaded files by other users.

for first option (user upload file)

I am using JavaScript to fetch file data and convert it into html data.

      beginFileHandling(e) {
            let file = (e.target.files || e.dataTransfer.files)[0]
            convertTodata(file) //this function has logic of reading file and convert it to data array for presentation in HTML
      }

but for the second option (user can choose server files)

I need to have file object to make it work by upper method convertTodata(file). How can I achieve it using JavaScript or nodejs.

suppose I have file on server at following path 'docs/Test-files/employee.xls' I am using xmlhttp to grab that file but how can I write it to JavaScript file object to use same method convertTodata(file).

            var result = null;
            var xmlhttp = new XMLHttpRequest();
            xmlhttp.open("GET", 'docs/Test-files/employee.xls', false);
            xmlhttp.send();
            if (xmlhttp.status == 200) {
                result = xmlhttp.responseText;
            }
kandarp
  • 991
  • 1
  • 14
  • 35
  • 1
    This answer shows how to process a file: https://stackoverflow.com/a/23797348/5734311 –  Feb 14 '18 at 12:02

0 Answers0