@@ -366,9 +366,11 @@ def add_xlsx_worksheet(workbook, worksheet_name, rows, fields):
366
366
"""
367
367
worksheet = workbook .add_worksheet (worksheet_name )
368
368
worksheet .set_default_row (height = 14 )
369
+ worksheet .freeze_panes (1 , 0 ) # Freeze the header row
370
+ cell_format = workbook .add_format ({"font_size" : 10 })
369
371
370
372
header = list (fields ) + ["xlsx_errors" ]
371
- worksheet .write_row (row = 0 , col = 0 , data = header )
373
+ worksheet .write_row (row = 0 , col = 0 , data = header , cell_format = cell_format )
372
374
373
375
errors_count = 0
374
376
errors_col_index = len (fields ) - 1 # rows and cols are zero-indexed
@@ -391,12 +393,22 @@ def add_xlsx_worksheet(workbook, worksheet_name, rows, fields):
391
393
row_errors .append (error )
392
394
393
395
if value :
394
- worksheet .write_string (row_index , col_index , str (value ))
396
+ worksheet .write_string (
397
+ row = row_index ,
398
+ col = col_index ,
399
+ string = str (value ),
400
+ cell_format = cell_format ,
401
+ )
395
402
396
403
if row_errors :
397
404
errors_count += len (row_errors )
398
405
row_errors = "\n " .join (row_errors )
399
- worksheet .write_string (row_index , errors_col_index , row_errors )
406
+ worksheet .write_string (
407
+ row = row_index ,
408
+ col = errors_col_index ,
409
+ string = row_errors ,
410
+ cell_format = cell_format ,
411
+ )
400
412
401
413
return errors_count
402
414
0 commit comments