How I can set the cell fill to transparent using xlwings? I understand that xl.range(XX).color = (r,g,b)
can be used to set the color, but is there a specific command for no fill? I would still like to see the cell boundaries.
Asked
Active
Viewed 5,492 times
3

Kev
- 118,037
- 53
- 300
- 385

Caleb Pearson
- 105
- 1
- 4
-
To get no fill in VBA you'd typically use `rng.Interior.ColorIndex = xlNone` – Tim Williams Jul 21 '16 at 17:44
-
1Unless I'm mistaken, he's not asking about VBA. He's trying to use a python library (xlwings). The question you've referenced as a duplicate doesn't apply, IMO. – schoolie Jul 21 '16 at 17:48
-
Yes, I am asking about the python library xlwings, not VBA. – Caleb Pearson Jul 21 '16 at 18:05
-
Sorry about that - somehow I'd gotten the idea that xlWings was a wrapper around the "native" VBA methods - not the case as you note. – Tim Williams Jul 21 '16 at 22:46
-
1`Range('A2').color = None` according to http://docs.xlwings.org/en/stable/api.html?highlight=color#xlwings.Range.color – Tim Williams Jul 21 '16 at 22:47
1 Answers
0
If you set color
to None
, the background colour of your range will be transparent.
import xlwings as xw
# Connect to the Excel file
wb = xw.Book(EXCEL_FILENAME)
sht = wb.sheets[EXCEL_SHEETNAME]
sht.range('A1:C10').color = None

Romain Capron
- 1,565
- 1
- 18
- 23