如何通过Outlook使用to_html命令保留这些样式?文件对我来说有点缺乏。(df.style
.format(percent)
.applymap(color_negative_red, subset=['col1', 'col2'])
.set_properties(**{'font-size': '9pt', 'font-family': 'Calibri'})
.bar(subset=['col4', 'col5'], color='lightblue'))
import win32com.client as win32
outlook = win32.Dispatch('outlook.application')
mail = outlook.CreateItem(0)
mail.Subject = subject_name
mail.HTMLbody = ('
Title of Data
' + df.to_html(index=False, classes=????????) '')
mail.send
to-uhtml文档显示,有一个类命令可以放在to-uhtml方法中,但我无法理解。似乎我的数据框也没有我指定的样式。
如果我尝试:df = (df.style
.format(percent)
.applymap(color_negative_red, subset=['col1', 'col2'])
.set_properties(**{'font-size': '9pt', 'font-family': 'Calibri'})
.bar(subset=['col4', 'col5'], color='lightblue'))
然后df现在是一个样式对象,您不能使用它来创建html。
编辑-这是我目前正在做的修改我的表。这很有效,但我不能保留pandas提供的.style方法的酷特性。email_paragraph = """
"""
email_caption = """
"""
email_style = '''
table, th, td {border: 0px solid black; background-color: #eee; padding: 10px;}
th {background-color: #C6E2FF; color:black; font-family: Tahoma;font-size : 13; text-align: center;}
td {background-color: #fff; padding: 10px; font-family: Calibri; font-size : 12; text-align: center;}
'''