views:

62

answers:

1

xlrd makes it pretty easy to know what the last column is.

is there an easy way using win32com?

I have tried using ws.UsedRange.Rows.Count but this doesnt seem to give a correct answer.

+2  A: 

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
John Machin