Native JS ActiveXObject get execl inside the value _javascript tips

Source: Internet
Author: User

Today, a programmer gave an Excel table, which has more than 100 data, called me a copy of the data to the corresponding functions such as put ("Gaga1", "GAGA2"), so that a word, I copy more than 100 times, fuck. I said you can read it in Java yourself! He said with Java to run more than half an hour, I think fuck, is you do not understand Java! At this time own heart of millions of grass mud horse in Pentium!!!!!!

So I went to find a JS method to read the data in Excel, to be modified without half an hour! It's fuck!.

The data inside the execl is probably like this:

The effect of implementing the output is:

JS Source:

Copy Code code as follows:

function Readthis () {
var tempstr = "";
var filepath= document.all.upfile.value;
var oXL = new ActiveXObject ("Excel.Application");
var owb = OXL.Workbooks.open (FilePath);
Owb.worksheets (1). Select ();
var len = 100; The number of data to be fetched
var osheet = Owb.activesheet;
try{
for (var i=1;i<= len;i++) {
tempstr+= ("Put ()" +osheet.cells (i,1). value+ "\", \ "" +osheet.cells (i,2). value+ "\"); + "<br>"; 1 and 2 represent the first column and the second column, respectively.
}
}catch (e) {
Document.all.txtArea.innerHTML = TempStr;
}
Document.all.txtArea.innerHTML = TempStr;
Oxl.quit ();
CollectGarbage ();
}

HTML Source code:
Copy Code code as follows:

<input type= "File" id= "Upfile"/><input type= "button" onclick= "Readthis ();" Value= read ">
<div id= "Txtarea" style= "width:500px;height:500px;" ></div>

Because ActiveXObject only IE support, so run only use IE to run, now think of this method!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.