I would like to create a Flask app to render dynamically an excel sheet. My need is the following: someone created (a long time ago) a complex excel document, having many sheets with formula across the sheets. The "last" sheet of the excel displays valuable information (that can be updated regularly by someone on the server side, like every minute), and I would like to broadcast via a web server. Currently what I'm doing (but it's not working), is to read the sheet with pandas (or openpyxl) and render the results via a Flask app:
from flask import Flask
from flask import render_template
app = Flask(__name__)
@app.route('/', methods=('POST', 'GET'))
def index():
html = pd.read_excel("foo.xlsx", sheetname="Sheet_1").to_html()
return render_template('index.html', html_code=html)
and in my html template :
{% block content %}
<h1>From excel:</h1>
{{ html_code|safe }}
{% endblock %}
What is not working (from more problematic to less): * Pandas (or Openpyxl) does not redo the excel formula (it displays the formula, without resolving them). Is there a way to do that ? * How to "slow down" or control the refresh rate of the Flask index page ? * Is there a way to also render the formating of the excel sheet ? (like borders, colors, ....)
Also, I know my architecture is pretty awkward and probably not working in fine, so if you guys have another simple architecture that allows someone to regularly edit (like every minutes) an excel and render a sheet ? The only constraint that I have is that I have to use the excel, and I don't want to save every minutes a .mht or .html from the excel file.
Many thanks !!