Adding style style more than the Excel sheet, but only the last one style saved successfully, here also in the copy, but is the style of the front cannot save, have which friend know, help me to solve the
Here is my key code
Rows_cols_list=[[{Decimal (' 2.232221 ') : [584, 6]}, {a Decimal (' 2.232221 ') : [584, 6]}, {a Decimal (' 0.544540 ') : [587, 6]}, {a Decimal (' 0.544540 ') : [587, 6]}, {a Decimal (' 0.544540 ') : [587, 6]}, {a Decimal (' 4.782255 ') : [588, 6]}, {a Decimal (' 4.782255 ') : [588, 6]}, {a Decimal (' 4.782255 ') : [588, 6]}, {a Decimal (' 3.779726 ') : [589, 6]}, {a Decimal (' 3.779726 ') : [589, 6]}, {a Decimal (' 3.779726 ') : [589, 6]}...]]
Def SettingStyle (path, rows_cols_list source_index) :
"" "
Set the style
The Args:
Path: save the path
Rows_cols_list: rows of data
Source_index: column data
"" "
Workbook=XLRD. Open_workbook (path)
Wb=copy (workbook)
Ws=wb. Get_sheet (source_index)
The pattern=XLWT. The pattern ()
The pattern. The pattern=XLWT. Pattern. SOLID_PATTERN
The pattern. Pattern_fore_colour=5
Style=XLWT. XFStyle ()
Style. The pattern=pattern
For rows_cols rows_cols_list in:
For the data in rows_cols. Keys () :
Rc=rows_cols. Get (data)
# print (rc [0], rc [1], the data)
# ws. Write (3, 2, 71067.5, style)
Ws. Write (rc [0], rc [1], the data, style)
Wb. Save (path)