Skip to content

Instantly share code, notes, and snippets.

@pasunboneleve
Created January 14, 2013 04:55
Show Gist options
  • Save pasunboneleve/4527849 to your computer and use it in GitHub Desktop.
Save pasunboneleve/4527849 to your computer and use it in GitHub Desktop.
Code for generating colours list for use with xlwt. In XLS format, of course ;7)
# -*- coding: utf-8 -*-
"""
Created on Mon Jan 14 15:36:36 2013
@author: daniel.vianna
"""
import xlwt as xlwt
import pandas as pd
conv = pd.io.parsers.CellStyleConverter()
wb = xlwt.Workbook()
ws = wb.add_sheet('sheet')
def stylefunc(i):
styledict = {"pattern": {"pattern": "solid", "fore_colour": i}}
return conv.to_xls(styledict)
[ws.row(i).write(0,i,stylefunc(i)) for i in range(100)]
wb.save('colours.xls')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment