Fix import

This commit is contained in:
2026-03-31 17:15:43 +03:00
parent 0be7109df4
commit abb4200215
2 changed files with 22 additions and 2 deletions
@@ -575,6 +575,10 @@ $xlsHeaders = $template['xls_headers'] ? json_decode($template['xls_headers'], t
while (headers.length > 0 && headers[headers.length - 1] === '') {
headers.pop();
}
headers = headers.map((h, i) => {
h = h.replace(/[\r\n\t]+/g, ' ').trim();
return h === '' ? `__empty_${i + 1}__` : h;
});
console.log("Intestazioni estratte (manual):", headers);
availableXlsColumns = [...headers];
usedColumnsFromDB = [];
@@ -707,8 +711,11 @@ $xlsHeaders = $template['xls_headers'] ? json_decode($template['xls_headers'], t
while (headers.length > 0 && headers[headers.length - 1] === '') {
headers.pop();
}
// Final clean: ensure no whitespace-only entries sneak through
headers = headers.map(h => h.replace(/[\r\n\t]+/g, ' ').trim());
// Final clean + name empty columns to match __empty_N__ convention
headers = headers.map((h, i) => {
h = h.replace(/[\r\n\t]+/g, ' ').trim();
return h === '' ? `__empty_${i + 1}__` : h;
});
console.log("Logical headers:", headers, `(${headers.length} columns from ${rawRow.length} physical)`);
availableXlsColumns = [...headers];
usedColumnsFromDB = [];