<s> import xlwt <EOL> import datetime <EOL> ezxf = xlwt . easyxf <EOL> def write_xls ( file_name , sheet_name , headings , data , heading_xf , data_xfs ) : <EOL> book = xlwt . Workbook ( ) <EOL> sheet = book . add_sheet ( sheet_name ) <EOL> rowx = <NUM_LIT:0> <EOL> for colx , value in enumerate ( headings ) : <EOL> sheet . write ( rowx , colx , value , heading_xf ) <EOL> sheet . set_panes_frozen ( True ) <EOL> sheet . set_horz_split_pos ( rowx + <NUM_LIT:1> ) <EOL> sheet . set_remove_splits ( True ) <EOL> for row in data : <EOL> rowx += <NUM_LIT:1> <EOL> for colx , value in enumerate ( row ) : <EOL> sheet . write ( rowx , colx , value , data_xfs [ colx ] ) <EOL> book . save ( file_name ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import sys <EOL> mkd = datetime . date <EOL> hdngs = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> kinds = '<STR_LIT>' . split ( ) <EOL> data = [ <EOL> [ mkd ( <NUM_LIT> , <NUM_LIT:7> , <NUM_LIT:1> ) , '<STR_LIT>' , <NUM_LIT:1000> , <NUM_LIT> , <NUM_LIT> , '<STR_LIT>' ] , <EOL> [ mkd ( <NUM_LIT> , <NUM_LIT:12> , <NUM_LIT> ) , '<STR_LIT>' , - <NUM_LIT:100> , <NUM_LIT> , - <NUM_LIT> , '<STR_LIT>' ] , <EOL> ] + [ <EOL> [ mkd ( <NUM_LIT> , <NUM_LIT:6> , <NUM_LIT:30> ) , '<STR_LIT>' , <NUM_LIT:100> , <NUM_LIT> , <NUM_LIT> , '<STR_LIT>' ] , <EOL> ] * <NUM_LIT:100> <EOL> heading_xf = ezxf ( '<STR_LIT>' ) <EOL> kind_to_xf_map = { <EOL> '<STR_LIT:date>' : ezxf ( num_format_str = '<STR_LIT>' ) , <EOL> '<STR_LIT:int>' : ezxf ( num_format_str = '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ezxf ( '<STR_LIT>' , <EOL> num_format_str = '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ezxf ( num_format_str = '<STR_LIT>' ) , <EOL> '<STR_LIT:text>' : ezxf ( ) , <EOL> } <EOL> data_xfs = [ kind_to_xf_map [ k ] for k in kinds ] <EOL> write_xls ( '<STR_LIT>' , '<STR_LIT>' , hdngs , data , heading_xf , data_xfs ) </s>
