win32com equivalent of xlrd's sheet.ncols
xlrd makes it pretty easy to know what the last column is.
is there an easy way using win32com?
I have t开发者_如何学运维ried using ws.UsedRange.Rows.Count but this doesnt seem to give a correct answer.
That's defined to give the count of rows in the used range (which may not start at cell A1
). You need the number of columns in the worksheet.
Try something like this:
used = ws.UsedRange
nrows = used.Row + used.Rows.Count - 1
ncols = used.Column + used.Columns.Count - 1
精彩评论