fax발송 엑셀불러오기 .xls 적용
This commit is contained in:
parent
4531dc86c6
commit
d25c836e18
@ -232,7 +232,22 @@ function excelFileChange(file) {
|
||||
var workbook = XLSX.read(data, {type: 'array'});
|
||||
var firstSheet = workbook.Sheets[workbook.SheetNames[0]];
|
||||
var jsonData = XLSX.utils.sheet_to_json(firstSheet, {header: 1});
|
||||
findInvalidDBCharacters(jsonData);
|
||||
processExcelData(jsonData);
|
||||
} else if (extension === 'xls') {
|
||||
var data = e.target.result;
|
||||
var workbook = XLSX.read(data, { type: 'binary' });
|
||||
var firstSheet = workbook.Sheets[workbook.SheetNames[0]];
|
||||
var jsonData = XLSX.utils.sheet_to_json(firstSheet, { header: 1 });
|
||||
|
||||
// 문제 데이터를 확인하는 함수 호출
|
||||
findInvalidDBCharacters(jsonData);
|
||||
|
||||
|
||||
processExcelData(jsonData);
|
||||
} else if (extension === 'txt') {
|
||||
var textData = e.target.result;
|
||||
processTextData(textData);
|
||||
} else {
|
||||
alert('지원되지 않는 파일 형식입니다.');
|
||||
}
|
||||
@ -241,7 +256,31 @@ function excelFileChange(file) {
|
||||
};
|
||||
if (extension === 'xlsx') {
|
||||
reader.readAsArrayBuffer(file);
|
||||
}
|
||||
} else if (extension === 'xls') {
|
||||
reader.readAsBinaryString(file); // xls 파일에 적절한 read 메서드 호출
|
||||
} else if (extension === 'txt') {
|
||||
reader.readAsText(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//문제 데이터를 확인하는 함수
|
||||
function findInvalidDBCharacters(jsonData) {
|
||||
console.log('DB 입력 값 검사 중...');
|
||||
const invalidCharPattern = /[\uD800-\uDBFF][\uDC00-\uDFFF]/; // 4바이트 유니코드 문자 (이모지 등)
|
||||
for (let rowIndex = 0; rowIndex < jsonData.length; rowIndex++) {
|
||||
const row = jsonData[rowIndex];
|
||||
if (Array.isArray(row)) {
|
||||
for (let colIndex = 0; colIndex < row.length; colIndex++) {
|
||||
const cell = row[colIndex];
|
||||
if (typeof cell === 'string' && invalidCharPattern.test(cell)) {
|
||||
console.warn('허용되지 않는 문자: row', rowIndex + 1,', col ', colIndex + 1, ', value:', cell);
|
||||
// 허용되지 않는 문자를 제거 (선택 사항)
|
||||
row[colIndex] = cell.replace(invalidCharPattern, '');
|
||||
console.log('수정된 값:', row[colIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user