سؤال

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.

هل كانت مفيدة؟

المحلول

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
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top