慕盖茨1488219
以下是我将作为针对xlutils 1.4.1的补丁提出的代码使用示例# coding: asciiimport xlrd, xlwt# Demonstration of copy2 patch for xlutils 1.4.1# Context:# xlutils.copy.copy(xlrd_workbook) -> xlwt_workbook# copy2(xlrd_workbook) -> (xlwt_workbook, style_list)# style_list is a conversion of xlrd_workbook.xf_list to xlwt-compatible styles# Step 1: Create an input file for the demodef create_input_file():
wtbook = xlwt.Workbook()
wtsheet = wtbook.add_sheet(u'First')
colours = 'white black red green blue pink turquoise yellow'.split()
fancy_styles = [xlwt.easyxf(
'font: name Times New Roman, italic on;'
'pattern: pattern solid, fore_colour %s;'
% colour) for colour in colours]
for rowx in xrange(8):
wtsheet.write(rowx, 0, rowx)