@@ -70,23 +70,24 @@ def write_error_in_xlsx(self):
70
70
infile = BytesIO (base64 .b64decode (self .datas ))
71
71
wb = openpyxl .load_workbook (filename = infile )
72
72
ws = self ._get_worksheet (wb )
73
+ ws .column_dimensions ['A' ].hidden = False
73
74
74
75
# we clear the error col if exist
75
76
if ws ["A1" ].value == _ ("#Error" ):
76
77
ws .delete_cols (1 )
77
78
ws .insert_cols (1 )
78
79
ws .cell (1 , 1 , value = _ ("#Error" ))
79
- last_row_idx = 0
80
- for chunk in self .chunk_ids :
81
- for message in chunk .messages :
82
- if "rows" in message :
83
- last_row_idx = message ["rows" ]["to" ]
84
- ws .cell (message ["rows" ]["to" ], 1 , value = message ["message" ].strip ())
80
+ for chunk in self .chunk_ids .filtered (lambda c : c .nbr_error > 0 ):
81
+ for key , message in chunk .messages .items ():
82
+ if "rows" in key :
83
+ ws .cell (message ["rows" ]["to" ], 1 , value = message )
85
84
else :
86
85
# If no row are specify, this is a global message
87
86
# that should be applied until the end of the chunk
88
- for idx in range (last_row_idx , chunk .stop_idx + 1 ):
89
- ws .cell (idx , 1 , value = message ["message" ].strip ())
87
+ for idx in range (chunk .start_idx , chunk .stop_idx + 1 ):
88
+ if self .pattern_config_id .nr_of_header_rows == 2 and idx == 2 :
89
+ idx = idx + 1
90
+ ws .cell (idx , 1 , value = message )
90
91
output = BytesIO ()
91
92
wb .save (output )
92
93
self .datas = base64 .b64encode (output .getvalue ())
0 commit comments