我正在通过 javascript 读取 Excel 文件 ..
<button onclick="myStopFunction()">Stop Meter</button>
var myVar=setInterval(function(){readdata(1,2)},2000);
function myStopFunction()
{
clearInterval(myVar);
}
读取excel文件的代码
var xVal = 1;
var yVal = 2
function readdata(x,y) {
x = xVal;
y = yVal;
try {
var excel = new ActiveXObject("Excel.Application");
excel.Visible = false;
var excel_file = excel.Workbooks.Open("D:\\Test1.xls");// alert(excel_file.worksheets.count);
var excel_sheet = excel_file.Worksheets("Sheet1");
var data = excel_sheet.Cells(x, y).Value;
//alert(data);
drawWithexcelValue(data);
xVal = xVal + 1;
excel.Application.Quit();
}
catch (ex) {
alert(ex);
}
}
现在我想以这样的方式摆脱停止计,当excel值变为空白或空时,它将退出..如何做到这一点我已经尝试过这样的事情
if(xVal==null& xVal=="")
{
clearInterval(myVar);
}
但我没有成功