Setting trendline name in Chart fails with "Error saving workbook: 'str' object has no attribute 'to_tree"
This was an issue may be a bug.<br> Raised in Stackoverflow Openpyxl Post "how to use openpyxl modify trendline name". <br> In attempting to answer the question this what I found.<br> Tested with the latest release 3.1.2 and all Line Numbers quoted refer to that release. When creating a Chart (Scatter in this case) and setting the name of a trendline for the Chart an attribute error is returned when the workbook is saved. The name for the trendline is '123'.<br> `"Error saving workbook: 'str' object has no attribute 'to_tree'` Reason; The error comes from the `serialisable.py` `to_tree` function @ line 106 When the 'tagname' is (str) 'trendline'<br> and the item being processed is (str) 'name' the following variables are set; line 128: child_tag = (str) 'name' line 130: obj = (str) '123' At line 149 the child_tag 'name' is checked but fails because 'name' is not in `self.__nested__` <br> line 149: `if child_tag in self.__nested__:` `self.__nested__` contains other parameters that can be set like 'dispEq', 'dispRSqr', 'forward' etc but not name. Code then drops to line 154 <br> line 154: `node = obj.to_tree(child_tag)` Given that 'obj' is a string for these values the line fails with the error;<br> `AttributeError: 'str' object has no attribute 'to_tree'` As a test I edited `trendline.py` to change 'name' to a NestedString and this did rectify the issue for the provided sample code.
issue