开发者

win32com equivalent of xlrd's sheet.ncols

开发者 https://www.devze.com 2023-01-01 23:05 出处:网络
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 ans

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
0

精彩评论

暂无评论...
验证码 换一张
取 消