Home > Web Front-end > JS Tutorial > body text

Native js ActiveXObject gets the value in execl_javascript skills

WBOY
Release: 2016-05-16 17:17:55
Original
1046 people have browsed it

Today, a programmer gave me an excel table with more than a hundred pieces of data, and asked me to copy the data one by one into the corresponding functions, such as put("gaga1", "gaga2"). In this sentence, You want me to copy it more than a hundred times, fuck. I just said you can read it yourself using java! He said that it would take more than half an hour to run using Java, and I thought to myself, fuck, you don’t know Java very well! At this time, millions of grass and mud horses were galloping in my heart!!!!!!

So I found a js method to read the data in excel, and it only took half an hour to modify it! What a fuck!

The data in execl is roughly like this:
Native js ActiveXObject gets the value in execl_javascript skills
The output effect is:
Native js ActiveXObject gets the value in execl_javascript skills
js source code:

Copy code The code is 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; // How many pieces of data to get
var oSheet = oWB.ActiveSheet;
try{
for(var i=1;i<= len; i ){
tempStr =("put("" oSheet.Cells(i,1).value "","" oSheet.Cells(i,2).value "");") "
"; // 1 and 2 represent the first and second columns respectively
}
}catch(e){
document.all.txtArea.innerHTML = tempStr;
}
document .all.txtArea.innerHTML = tempStr;
oXL.Quit();
CollectGarbage();
}

html source code:
Copy code The code is as follows:




Because ActiveXObject is only supported by IE, it can only be run using IE. Now I think of this method!
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template