ValueError: No format component named 'bottom'
AhmedAEB opened this issue · comments
formatz = get_effective_format(Stock, 'B5')
Heres my code^
I keep getting the ValueError
Yes, this is a bug. I have added test coverage, solved the bug, and am making a new release now.
Release 0.0.5 is now in PyPI.
I am still receiving the error with this line.
get_effective_format(Stock, 'C57')
Am I doing anything wrong?
Here's the full error:
Traceback (most recent call last): File "C:\Users\dabos\Desktop\SneakerDXB x FlexxDXB\TEST PY\formatting test.py", line 14, in <module> get_effective_format(Stock, 'C57') File "C:\Python34\lib\site-packages\gspread_formatting.py", line 66, in get_effective_format return CellFormat.from_props(props) if props else None File "C:\Python34\lib\site-packages\gspread_formatting.py", line 215, in from_props return _props_to_component(_underlower(cls.__name__), props) File "C:\Python34\lib\site-packages\gspread_formatting.py", line 180, in _props_to_component v = _props_to_component(k, v) File "C:\Python34\lib\site-packages\gspread_formatting.py", line 180, in _props_to_component v = _props_to_component(k, v) File "C:\Python34\lib\site-packages\gspread_formatting.py", line 176, in _props_to_component raise ValueError("No format component named '%s'" % class_alias) ValueError: No format component named 'bottom'
Hm. There are two components with bottom
attributes: borders
and padding
. I’ve tested both of these by setting them on a cell range, then getting user-entered and effective formats for a cell in that range. These tests pass in the 0.0.5 release.
I’ll post some debugging code that you can execute for yourself, in about 1 minute.
Sent with GitHawk
If your worksheet is the variable Stock
, put this code right before your get_effective_format call. Then post the printed output to this issue.
resp = Stock.spreadsheet.fetch_sheet_metadata({
'includeGridData': True,
'ranges': [‘%s!%s’ % (Stock.title, ‘C57’)],
'fields': 'sheets.data.rowData.values.effectiveFormat'
})
props = resp['sheets'][0]['data'][0]['rowData'][0]['values'][0].get('effectiveFormat')
print(props)
Sent with GitHawk
Here is the printed output:
{'verticalAlignment': 'BOTTOM', 'padding': {'right': 3, 'bottom': 2, 'left': 3, 'top': 2}, 'textFormat': {'italic': False, 'underline': False, 'foregroundColor': {}, 'strikethrough': False, 'fontFamily': 'arial,sans,sans-serif', 'fontSize': 10, 'bold': False}, 'hyperlinkDisplayType': 'PLAIN_TEXT', 'borders': {'bottom': {'color': {}, 'style': 'SOLID', 'width': 1}, 'top': {'color': {}, 'style': 'SOLID', 'width': 1}}, 'wrapStrategy': 'OVERFLOW_CELL', 'horizontalAlignment': 'CENTER', 'backgroundColor': {'green': 1, 'red': 1, 'blue': 1}}
I can now use this as a workaround to gain the format values that i need.
@AhmedAEB I'm sorry for the delay in commenting on your reported issue. Using the debugging output you provided above, both on May 1 when you provided it and today -- I can pass the debugging output's literal Python dictionary to gspread_formatting.CellFormat.from_props
function and receive a nice, happy CellFormat object without an error. Perhaps you were using 0.0.4 release by mistake in your most recent test?
I hope things worked out OK for you in May...