Ask Your Question
0

How do I conditional format excel based on cell value using PSSE excelpy?

asked 2020-09-12 10:24:18 -0600

Automation Guy gravatar image

Hello Friends, I would like to know how do I format an excel cell based on cell value?

Example: say cell A1 has value of 70. I wanted to set the background color of the cell to GREEN if the value is less than 85 and YELLOW if the value is between 85 and 95 and RED if the value is over 95.

I'm new to PSSE python and couldn't find any method in PSSE API document that does the above.

Please help and thanks in advance.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-09-24 13:59:59 -0600

cp27643 gravatar image

updated 2020-09-24 14:01:38 -0600

There is no fill method in excelpy, but there is font color changes and some other formatting methods available that might be of some use. You'd essentially be post processing after exporting the data to an excel workbook. I'd recommned importing excelpy and running help(excelpy) in the terminal to get the docstrings of the module and paste those into notepad and have a look around to see all of the methods available to you.

import excelpy

save_location = r'C:\Users\cphillips2\Downloads\testing1.xlsx'

wb = excelpy.workbook()

wb.set_cell('a2', 'Hello World')

wb.font_color(address='a2', color='green')

wb.save(save_location)

wb.close()

If you are generally needing more complex formatting, I'd look to excelpy to get the data from pss/e to excel, but then another module like xlrd or xlwings to post process the excel file and format how you'd like it.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

1 follower

Stats

Asked: 2020-09-12 10:24:18 -0600

Seen: 519 times

Last updated: Sep 24 '20