问题
I'm a new Dev , trying to pass Pandas DataFrame to Tabulator , it works but the table is so messed up
original file : original file in excel
without tabulator : to_html() render result
it renders fine as html but once i attach Tabulator to it everything is messed up .
after tabulator: after attaching tabulator to it using ID
the way i install it was copying and pasting all files in Dist to my app folder JS files in the JS folder and all CSS files in CSS folder
in HTML head :
<link href="{{ url_for ('static', filename='css/tabulator.min.css') }}" rel="stylesheet"></link>
<script type="text/javascript" src="{{ url_for ('static', filename='tabulator.min.js') }}"></script>
HTML Body :
var table = new Tabulator("#tableId", {});
PYTHON :
df = pd.read_excel(destination)
return render_template('fileviewer.html',x=df.to_html(table_id='tableId'))
回答1:
Looking at the code you posted, the issue is that it is using th tags for the first cell of each row in the table instead of td tags. th tags should only be used in the thead not the tbody
来源:https://stackoverflow.com/questions/53470273/flask-pandas-to-tabulator-tables-are-all-messed-up