How do I get the correct sheet size?

Viewed 25

I use openpyxl to process xlsx files (in this case created with an Office AddIn thru Office.context.document.getFileAsync(Office.FileType.Compressed)). I open the workbook with:

  • read_only=True
  • data_only=True

I then get the dimensions of the sheets (with force=True). My problem is, that the returned dimensions describe the sheet size (as shown by Excel), not the non empty parts of it.

So I have a spreadsheet with 2 rows and 33 columns, where calculate_dimensions is returning A1:AG20710. I then have to process 20710 rows (which takes a very long time because 20710 to sheet.cell().value (even for one cell per row) take so long).

How can I prevent this?

0 Answers
Related