从javascript获取Excel工作表的行数 [英] get row count of excel sheet from javascript
本文介绍了从javascript获取Excel工作表的行数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用javascript获取我的excel工作表中的总行数. 这是我的代码
i am trying to get total number of rows in my excel sheet with javascript . here is my code
var Excel;
Excel = new ActiveXObject("Excel.Application");
Excel.Visible = false;
a= Excel.Workbooks.open("C:/work/ind.xls").ActiveSheet.Cells(1,1).value;
alert(a);
这显示了第一个索引的值,但是我想知道是否有任何选择获取此活动表的总行数.
this show the value at 1st index , but i was wondering if there is any option of getting the total rows of this active sheet .
谢谢
推荐答案
替换
a = Excel.Workbooks.open("C:/work/ind.xls").ActiveSheet.Cells(1,1).value;
使用
a = Excel.Rows.Count; //Depending on excel version, you will get either 65536 or 1048576
或
a = Excel.Workbooks.open("C:/work/ind.xls").ActiveSheet.Cells.UsedRange.Count; //It will provide total used rows.
注意:ActiveXObject仅在IE浏览器上可用.因此,每个其他用户代理都会引发错误
Note: ActiveXObject is available only on IE browser. So every other useragent will throw an error
这篇关于从javascript获取Excel工作表的行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文