python - Column and row dimensions in OpenPyXL are always None -


why openpyxl reading every row , column dimension none? case regardless of whether table created via openpyxl or within microsoft excel.

import openpyxl wb = openpyxl.load_workbook(r'c:\data\mytable.xlsx') ws = wb.active print ws.row_dimensions[1].height print ws.column_dimensions['a'].width 

prints none , none. these aren't hidden columns/rows. have dimensions when viewed in excel.

i know loading workbook iterators prevent dimension dictionaries being created, results in key errors, , i'm not using iterators here.

is there alternative way determine width/height of cell/row/column?

===============solution=================

thanks charlie, realized following best way list of row heights:

import openpyxl wb = openpyxl.load_workbook(r'c:\data\test.xlsx') ws = wb.active rowheights = [ws.row_dimensions[i+1].height in range(ws.max_row)] rowheights = [15 if rh none else rh rh in rowheights] 

rowdimension , columndimension objects exist when defaults overwritten. ws.row_dimensions[1].height none until assigned value.

the default values are: {'defaultrowheight': '15', 'basecolwidth': '10'}


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -