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'})

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group