0

I am working on a web that needs to read data from an xlsx. I´ve looked around and found many instances of people using the input file button to load one archive from the user side and acces it just with the id, it works fine.

<input type="file" id="fileUpload" />
<input type="button" id="upload" value="Upload" onclick="Upload()" />
<script type="text/javascript">
var fileUpload = document.getElementById("fileUpload");
</script>

What i need should be easyer, but i can´t find a way. The file is in the server, it is an xlsx. what tag shoud i use and how?

an example of what i need would be something like:

<file id="fileUpload" src="myxlsx.xlsx" />
<script type="text/javascript">
var fileUpload = document.getElementById("fileUpload");
</script>

but that works

  • I don't know why you think that what you are doing should be easy. An Excel file's contents are not native to HTML or JavaScript. And, the code you've shown has nothing to do with Excel. – Scott Marcus Oct 24 '20 at 16:01
  • yes I know, the excell part is another issue that i am working on. In my tests i select the excell and try things, what i need it is the line to select the excell from the html code, and stop the need to upload it with the form everytime. I need a substitute for the lines in my questios. an example would be – Gonzalo Gomez Martinez Oct 24 '20 at 16:07
  • This is not a question of HTML. There is no "tag" that will solve your problem. JavaScript is prevented from accessing the File System for security reasons. If you need to access the Excel file after it's been uploaded, you'll need a custom library. Look at the duplicate link. – Scott Marcus Oct 24 '20 at 16:14
  • the file is in the server, i made it for the web, is there no way to embed or src or whatever just from the html? – Gonzalo Gomez Martinez Oct 24 '20 at 16:19
  • No, there isn't. HTML can't access the contents of files. It can only cause then to be uploaded or downloaded. – Scott Marcus Oct 24 '20 at 16:26
  • you are breaking my heart – Gonzalo Gomez Martinez Oct 24 '20 at 16:29
  • You're question is analogous to saying "What is the math that I would use to grow a tomato?" I'm not doing anything but telling you that you don't use HTML to do what you are asking to do and what you are trying to do isn't just a simple line of code. It can be done, but it involves more than what you believe it should. – Scott Marcus Oct 24 '20 at 16:31
  • ok thanks, i´ll try a diferent approach then – Gonzalo Gomez Martinez Oct 24 '20 at 16:35

0 Answers0