First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!

Ask Your Question
0

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

asked Sep 12 '0

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.

1 answer

Sort by » oldest newest most voted
0

answered Sep 24 '0

cp27643 gravatar image

updated Sep 24 '0

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.

link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.
Want to format code in your answer? Here is a one minute demo on Youtube

Add Answer

[hide preview]

Question Tools

1 follower

Stats

Asked: Sep 12 '0

Seen: 535 times

Last updated: Sep 24 '20