cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

how to add the background color to excel sheet by python

databicky
Contributor II

i just want to add color to excel sheet by python to specific cells, and i done that, but i need to exclude the header column, then if i tried the same method to other sheet it doesn't worked.​

but that bg color addition is reflected in one sheet but the same method of code is not able to use to other sheet

i​ just want to add color based on cell address.

1 ACCEPTED SOLUTION

Accepted Solutions
3 REPLIES 3

Hubert-Dudek
Esteemed Contributor III

from the pandas df i added the below color, but based on the same method i am not able to add bg in other sheets. it is not reflecting those things

And how can we extend the width size of the particular column in excel by python?​

Hubert-Dudek
Esteemed Contributor III

Separate dataframe for every sheet:

with pd.ExcelWriter('output.xlsx') as writer:  
 
     df1.to_excel(writer, sheet_name='Sheet_name_1')
     df2.to_excel(writer, sheet_name='Sheet_name_2')

For width, but I never used that:

df.style.set_properties(subset=['column'], **{'width': '300px'})

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.