@@ -366,9 +366,11 @@ def add_xlsx_worksheet(workbook, worksheet_name, rows, fields):
366366 """
367367 worksheet = workbook .add_worksheet (worksheet_name )
368368 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 })
369371
370372 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 )
372374
373375 errors_count = 0
374376 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):
391393 row_errors .append (error )
392394
393395 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+ )
395402
396403 if row_errors :
397404 errors_count += len (row_errors )
398405 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+ )
400412
401413 return errors_count
402414
0 commit comments