我正在尝试通过 python 发送 Outlook 邮件。我使用数据框从 excel 文件中导入一些数据,经过一些过滤后,我将它们发送到邮件正文所在的位置:
body = '<html><body>'+df.to_html()+'</body></html>'
我得到一个表格,但单元格没有justify='left/write'
对齐。我不能使用,因为我希望单元格居中对齐,而不仅仅是列标题。我使用过样式,但它也不起作用:
df.style.set_properties(subset=df.columns,**{'width':'10em', 'text-align':'center'})\
我也试过这个,但没有用。
p=HTML(df.to_html(classes= 'table text-align:center'))
在浏览了类似的问题后,我找到了另一个解决方案:
s = df.style.set_properties(**{'text-align': 'center'}) s.render()
但是它使border
表的消失。所以我修改了它:
s = df.style.set_properties(**{'text-align': 'center','border-color':'Black','border-width':'thin','border-style':'dotted'})
这给予border
细胞。不过看起来each cell
是个人里面的textbox,
不像一个table
。我如何完成这项工作?
最终结果如下所示:
米琪卡哇伊
相关分类