xlwings——Python for Excel——xlwings如何獲取有數據的所有行數和列數

used_range
Used Range of Sheet.

Returns:	
Return type:	xw.Range
last_cell
Returns the bottom right cell of the specified range. Read-only.

Returns:	
Return type:	Range

 

import xlwings as xw

wb = xw.Book(r'F:\xlwings\OriginalData.xlsx')

sht = wb.sheets[0]

info = sht.used_range

nrows = info.last_cell.row
print(nrows)

ncolumns = info.last_cell.column
print(ncolumns)

 

發佈了23 篇原創文章 · 獲贊 18 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章