Fix import
This commit is contained in:
@@ -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 = [];
|
||||
|
||||
Reference in New Issue
Block a user