-
-
Save garymanley/19a981c7eacebfa9db476a020c749357 to your computer and use it in GitHub Desktop.
Use XL Formatter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Sat Oct 28 20:21:04 2017 | |
@author: garym | |
""" | |
import xlwings as xw | |
## I know that doing it this way is not recommended for code that gets shared but it works for me for this purpose | |
import sys | |
sys.path.append(r'C:\Users\garym\Documents\Python From Work\Python\Other') | |
import XLFormatting as XL | |
## Open Workbook | |
wb = xw.Book() | |
## Set value to Hellow World | |
xw.Range('A1').value = 'Hello World' | |
xw.Range('B5').value = 'Abc 123' | |
## Format the range using the function | |
XL.formatrange('A1','White','Black',1,1,'A1:A2','Right') | |
XL.formatrange('B5','Pink','Turq',1,2,'B5:B6','Center') | |
## Autofit the columns | |
xw.Range('A1:AI100').autofit() | |
## Save workbook | |
filename = (r'C:\Users\garym\Documents\Python From Work\Python\Other\test.xlsx') | |
wb.save(filename) | |
wb.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment