我是 XIST 的新手,但我一直在尝试阅读他们关于 html 的文档。不幸的是,我找不到有关如何设置表格中行颜色格式的示例。
我到目前为止的代码是:
with html.table() :
with html.th():
with html.td() :
+xsc.Text( "Org" )
with html.td() :
+xsc.Text( "Fullname" )
with html.td() :
+xsc.Text( "Age of File" )
# Data Rows
exists = manifest[manifest['Org File'] == 'Exists']
for index, row in exists.iterrows():
ageOfFile = str(row['Age of file'].days)
if ageOfFile == '1':
suffix = ' day'
else:
suffix = ' days'
if int(ageOfFile) > 3:
bgColour = 'red'
elif int(ageOfFile) > 1:
bgColour = 'orange'
else:
bgColour = 'white'
with html.tr() :
with html.td():
+xsc.Text('')
with html.td() :
+xsc.Text( row['Org_Code'] )
with html.td() :
+xsc.Text( row['Org_Fullname'] )
#with html.td('style="background-color:"' + bgColour) :
with html.td():
+xsc.Text(ageOfFile + suffix)
倒数第三行是我希望能起作用的(现在已注释掉)
请问有人有任何想法或知识可以帮助完成这项工作吗?
非常感谢。
兄弟
答案 0 :(得分:0)
经过多次尝试和错误,结果证明相对简单
<块引用>使用 html.tr(bgcolor='Green') :