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!