@@ -2367,7 +2367,7 @@ def xlformat_factory(format):
23672367 xlstyle .num_format_str = '#,##;[RED]-#,##'
23682368 elif isinstance (format , FormatPercent ):
23692369 zeros = '' .join (['0' ]* format .precision )
2370- xlstyle .num_format_str = '0.%s%;[RED]-0.%s%' % (zeros , zeros )
2370+ xlstyle .num_format_str = '0.%s%% ;[RED]-0.%s% %' % (zeros , zeros )
23712371 format .scale = 1.
23722372 else :
23732373 xlstyle = None
@@ -2376,12 +2376,14 @@ def xlformat_factory(format):
23762376
23772377 return format
23782378
2379- def rec2excel (r , ws , formatd = None , rownum = 0 ):
2379+ def rec2excel (r , ws , formatd = None , rownum = 0 , colnum = 0 ):
23802380 """
23812381 save record array r to excel pyExcelerator worksheet ws
23822382 starting at rownum. if ws is string like, assume it is a
23832383 filename and save to it
23842384
2385+ start writing at rownum, colnum
2386+
23852387 formatd is a dictionary mapping dtype name -> FormatXL instances
23862388
23872389 The next rownum after writing is returned
@@ -2399,14 +2401,20 @@ def rec2excel(r, ws, formatd=None, rownum=0):
23992401 formatd = dict ()
24002402
24012403 formats = []
2404+ font = excel .Font ()
2405+ font .bold = True
2406+
2407+ stylehdr = excel .XFStyle ()
2408+ stylehdr .font = font
2409+
24022410 for i , name in enumerate (r .dtype .names ):
24032411 dt = r .dtype [name ]
24042412 format = formatd .get (name )
24052413 if format is None :
24062414 format = defaultformatd .get (dt .type , FormatObj ())
24072415
24082416 format = xlformat_factory (format )
2409- ws .write (rownum , i , name )
2417+ ws .write (rownum , colnum + i , name , stylehdr )
24102418 formats .append (format )
24112419
24122420 rownum += 1
@@ -2419,12 +2427,12 @@ def rec2excel(r, ws, formatd=None, rownum=0):
24192427 format = formats [i ]
24202428 val = format .toval (val )
24212429 if format .xlstyle is None :
2422- ws .write (rownum , i , val )
2430+ ws .write (rownum , colnum + i , val )
24232431 else :
24242432 if safe_isnan (val ):
2425- ws .write (rownum , i , 'NaN' )
2433+ ws .write (rownum , colnum + i , 'NaN' )
24262434 else :
2427- ws .write (rownum , i , val , format .xlstyle )
2435+ ws .write (rownum , colnum + i , val , format .xlstyle )
24282436 rownum += 1
24292437
24302438 if autosave :
0 commit comments