我使用python 2.7和xlwt模块进行excel导出
我想设置我知道可以使用的单元格的背景颜色
style1 = xlwt.easyxf('pattern: pattern solid, fore_colour red;')
Run Code Online (Sandbox Code Playgroud)
但我想设置自定义颜色smth.比如#8a8eef或者是否有可能颜色的调色板,因为浅蓝色不起作用:)
谢谢
I have a dataframe
df = pd.DataFrame(columns = ['id', 'name', 'age'])
df.loc[len(df), :] = [1, 'John', 21]
df.loc[len(df), :] = [2, 'Mary', 19]
df.loc[len(df), :] = [3, 'Ann', 27]
df.loc[len(df), :] = [4, 'Ben', 18]
Run Code Online (Sandbox Code Playgroud)
I want to save it to excel file using xlsxwriter.
However, I want the age larger than 20 to be in red.
In other words, 21 and 27 should appear red in the excel file.
How to do it?
在将其标记为重复之前,我已经尝试了以下主题中的代码,但到目前为止没有一个对我有用:
我有代码可以生成三个 pandas 数据框,如下所示:
RowName Orders Market StartTime StopTime
Status
good A 9 gold 10:00:00 10:09:45
.
.
.
bad B 60 silver 07:54:43 08:02:12
RowName Orders Market StartTime StopTime
Status
good E 19 plat. 10:00:00 10:09:45
.
.
bad F 54 mercury 07:54:43 08:02:12
RowName Orders Market StartTime StopTime
Status
great D 3 alum. 10:00:00 10:09:45
.
.
ok C 70 bronze 07:54:43 08:02:12 …Run Code Online (Sandbox Code Playgroud)