flask pandas to tabulator tables are all messed up

浪子不回头ぞ 提交于 2019-12-24 10:17:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!