如何获得通过Excel COM接口select的行数和列数?

我可以通过应用程序的.Selection属性来获取区域。

(我使用python来访问Excel的COM接口)

例如,我想知道用户select了多less行和列

 input: user has selected A1:G8 output: the selected range starts from Column 1 (by selection.Column) the selected range starts from Row 1 (by selection.Column) the selected range is spanning 7 rows (by ?) the selected range is spanning 8 columns (by ?) 

我在看MSDN的Range接口 ,但是这个属性似乎对这个问题没有帮助。

从VBA,你可以做这样的事情:

 Debug.Print Selection.Rows.Count Debug.Print Selection.Columns.Count Debug.Print Selection.Row Debug.Print Selection.Column 

选中A1:G8,返回

 8 7 1 1 

这很容易翻译成Python>