OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

AttributeError: 'Typed' object has no attribute 'to_tree'

  • Thread starter Thread starter Hello World
  • Start date Start date
H

Hello World

Guest
While saving an excel file got via file upload in a html file through flask,

Code:

Code:
from flask import *
import xlsxwriter as xw
import xlwings as xwi

app = Flask(__name__)

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/submit', methods = ['POST'])
def submit():
    if 'f1' in request.files:
        f1 = load_workbook(request.files['f1'], data_only=True, read_only=False, keep_vba=True, rich_text=True)
            
    f1.save('output.xlsx')

Since the error was showing on charts, I tried deleting the existing charts and saving the excel workbook. still the error is same.

Code:
from flask import *
import xlsxwriter as xw
import xlwings as xwi

app = Flask(__name__)

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/submit', methods = ['POST'])
def submit():
    if 'f1' in request.files:
        f1 = load_workbook(request.files['f1'], data_only=True, read_only=False, keep_vba=True, rich_text=True)
    for sheet in f1.worksheets:
        for num, chart in enumerate(sheet._charts):
            del sheet._charts[num]
            
    f1.save('output.xlsx')

I got the following error:

Code:
File "C:\Anaconda3\Lib\site-packages\flask\app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Anaconda3\Lib\site-packages\flask\app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "C:\Anaconda3\Lib\site-packages\flask\app.py", line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Anaconda3\Lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Anaconda3\Lib\site-packages\flask\app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "C:\Anaconda3\Lib\site-packages\flask\app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Anaconda3\Lib\site-packages\flask\app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Anaconda3\Lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Anaconda3\Lib\site-packages\flask\app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Anaconda3\Lib\site-packages\flask\app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Users\SV21242\Desktop\excelAutomate\withFlask\index.py", line 26, in daily
f1.save('output.xlsx')
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\workbook\workbook.py", line 386, in save
save_workbook(self, filename)
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\writer\excel.py", line 294, in save_workbook
writer.save()
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\writer\excel.py", line 275, in save
self.write_data()
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\writer\excel.py", line 80, in write_data
self._write_charts()
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\writer\excel.py", line 124, in _write_charts
self._archive.writestr(chart.path[1:], tostring(chart._write()))
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\chart\_chart.py", line 150, in _write
return cs.to_tree()
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\chart\chartspace.py", line 193, in to_tree
tree = super(ChartSpace, self).to_tree()
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\descriptors\serialisable.py", line 154, in to_tree
node = obj.to_tree(child_tag)
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\descriptors\serialisable.py", line 154, in to_tree
node = obj.to_tree(child_tag)
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\chart\plotarea.py", line 135, in to_tree
return super(PlotArea, self).to_tree(tagname)
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\descriptors\serialisable.py", line 146, in to_tree
for node in nodes:
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\descriptors\sequence.py", line 114, in to_tree
el = v.to_tree(namespace=namespace)
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\chart\_chart.py", line 110, in to_tree
return super(ChartBase, self).to_tree(tagname, idx)
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\descriptors\serialisable.py", line 154, in to_tree
node = obj.to_tree(child_tag)
AttributeError: 'Typed' object has no attribute 'to_tree'

Sad stuff is I couldn't fine an answer or a related question Stackoverflow or any other websites.

Any help would be greatly helpful
<p>While saving an excel file got via file upload in a html file through flask,</p>
<p>Code:</p>
<pre><code>from flask import *
import xlsxwriter as xw
import xlwings as xwi

app = Flask(__name__)

@app.route('/')
def index():
return render_template('index.html')

@app.route('/submit', methods = ['POST'])
def submit():
if 'f1' in request.files:
f1 = load_workbook(request.files['f1'], data_only=True, read_only=False, keep_vba=True, rich_text=True)

f1.save('output.xlsx')
</code></pre>
<p>Since the error was showing on charts, I tried deleting the existing charts and saving the excel workbook. still the error is same.</p>
<pre><code>from flask import *
import xlsxwriter as xw
import xlwings as xwi

app = Flask(__name__)

@app.route('/')
def index():
return render_template('index.html')

@app.route('/submit', methods = ['POST'])
def submit():
if 'f1' in request.files:
f1 = load_workbook(request.files['f1'], data_only=True, read_only=False, keep_vba=True, rich_text=True)
for sheet in f1.worksheets:
for num, chart in enumerate(sheet._charts):
del sheet._charts[num]

f1.save('output.xlsx')
</code></pre>
<p>I got the following error:</p>
<pre><code>File "C:\Anaconda3\Lib\site-packages\flask\app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Anaconda3\Lib\site-packages\flask\app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "C:\Anaconda3\Lib\site-packages\flask\app.py", line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Anaconda3\Lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Anaconda3\Lib\site-packages\flask\app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "C:\Anaconda3\Lib\site-packages\flask\app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Anaconda3\Lib\site-packages\flask\app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Anaconda3\Lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Anaconda3\Lib\site-packages\flask\app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Anaconda3\Lib\site-packages\flask\app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Users\SV21242\Desktop\excelAutomate\withFlask\index.py", line 26, in daily
f1.save('output.xlsx')
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\workbook\workbook.py", line 386, in save
save_workbook(self, filename)
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\writer\excel.py", line 294, in save_workbook
writer.save()
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\writer\excel.py", line 275, in save
self.write_data()
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\writer\excel.py", line 80, in write_data
self._write_charts()
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\writer\excel.py", line 124, in _write_charts
self._archive.writestr(chart.path[1:], tostring(chart._write()))
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\chart\_chart.py", line 150, in _write
return cs.to_tree()
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\chart\chartspace.py", line 193, in to_tree
tree = super(ChartSpace, self).to_tree()
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\descriptors\serialisable.py", line 154, in to_tree
node = obj.to_tree(child_tag)
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\descriptors\serialisable.py", line 154, in to_tree
node = obj.to_tree(child_tag)
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\chart\plotarea.py", line 135, in to_tree
return super(PlotArea, self).to_tree(tagname)
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\descriptors\serialisable.py", line 146, in to_tree
for node in nodes:
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\descriptors\sequence.py", line 114, in to_tree
el = v.to_tree(namespace=namespace)
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\chart\_chart.py", line 110, in to_tree
return super(ChartBase, self).to_tree(tagname, idx)
File "C:\Anaconda3\lib\site-packages\openpyxl-3.1.4-py3.8.egg\openpyxl\descriptors\serialisable.py", line 154, in to_tree
node = obj.to_tree(child_tag)
AttributeError: 'Typed' object has no attribute 'to_tree'
</code></pre>
<p>Sad stuff is I couldn't fine an answer or a related question Stackoverflow or any other websites.</p>
<p>Any help would be greatly helpful</p>
 
Top