为什么我在读EXECL表时会出错,但是对于简单的就不会出错
<div id=windiv style= "display:none " title= ' <script>
var fori = 1;
var maxfor = 257; //防止表中没有循环终止匹配字符的最大循环次数
function reportError(msg,url,line)
{
alert( "当前页的脚本发生错误: \n\n信息: " + msg + "\n\n行: " + line + " fori = " + fori);
return true;
}
window.onerror = reportError;
var topwin = frameElement.document.parentWindow;
var excel = new ActiveXObject( "Excel.Application ");
excel.Visible = false;
var bk = excel.Workbooks.Open(topwin.excelpath,0,1);
for(; fori < maxfor; ++fori)
{if(!confirm(fori + " " +bk.Worksheets(1).Cells(topwin.ncell,fori).value)){break}
if( (bk.Worksheets(1).Cells(topwin.ncell,fori).value == undefined)
|| (bk.Worksheets(1).Cells(topwin.scell,fori).value == undefined)
|| (parseFloat(bk.Worksheets(1).Cells(topwin.scell,fori).value) == 0)
|| (bk.Worksheets(1).Cells(topwin.ncell,fori).value.match(/\d/g) == null ))
{
continue;
}
if(bk.Worksheets(1).Cells(1,fori).value.indexOf( "合计 ") > -1)
{
topwin.thearray[topwin.thearray.length] = "合计 " + bk.Worksheets(1).Cells(topwin.scell,fori).value + "件 ";
break;
}
topwin.thearray[topwin.thearray.length] = bk.Worksheets(1).Cells(topwin.ncell,fori).value + "有 " + bk.Worksheets(1).Cells(topwin.scell,fori).value + "件 ";
}
excel.Workbooks.Close();
excel.Quit();
excel = bk = null;
topwin.time2show();
</script> '> </div>
</body>
</html>
<script>
function show()
{
if(thearray.length > arri)
{
document.title = thearray[arri];
}else
{
arri = 0;
document.title = thearray[arri];
}
arri++;
}
function time2show()
{
setInterval( "show() ",time);
windiv.innerHTML = " ";
}
var excelpath = "F:/My Documents/我的工作/04进销存.xlsx "; //表的路径
var ncell = 3; //编号行
var scell = 439; //库存行
var thearray = new Array();
var arri = 0;
var time = 1500;
function readexcel()
{
windiv.innerHTML = ' <iframe id= "excelwin " src= "about:blank " style= "display:none " APPLICATION= "yes "> </iframe> ';
excelwin.document.write(windiv.title);
}
readexcel();
</script>
[解决办法]
"F:/My Documents/我的工作/04进销存.xlsx "; //表的路径
不要用中文试一试。
扩展名用.xls试一试。