代码如下:
Set excel=CreateObject("Excel.Application")
set openexcel=excel.Workbooks.Open("这里输入EXCEL路径")
rowcount =openexcel.ActiveSheet.UsedRange.Rows.Count
Columnscount =openexcel.ActiveSheet.UsedRange.Columns.count
print " 行数:"&rowcount&" 列数:"&Columnscount
openexcel.Close
excel.Quit
set openexcel=nothing
Set excel=nothing
'若想要获取Excel中指定sheet的行数和列数,函数如下:
Public function getrowandcol(filepath,sheetname)
'函数作用:获取EXCEL指定sheet的行数和列数
'参数说明
'filepath:EXCEL所在路径
'sheetname:需要统计行数和列数的SHEET名称
'用法示例:getrowandcol"D:\qqq.xlsx","sheet1"
Set excel=CreateObject("Excel.Application")
set openexcel=excel.Workbooks.Open(filepath)
openexcel.WorkSheets(sheetname).Activate
rowcount =openexcel.ActiveSheet.UsedRange.Rows.Count
Columnscount =openexcel.ActiveSheet.UsedRange.Columns.count
If openexcel.WorkSheets(sheetname).Cells(1,1 )="" and rowcount=1 and Columnscount=1 then
print sheetname&"中没有数据"
else
print sheetname&"的行数为:"&rowcount&" 列数:"&Columnscount
end if
openexcel.Close
excel.Quit
set openexcel=nothing
Set excel=nothing
End Function
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。