cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
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

Hubert-Dudek
Esteemed Contributor III
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'})

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local communityโ€”sign up today to get started!

Sign Up Now