Merge branch 'hylee'
This commit is contained in:
commit
2c5863086a
@ -48,6 +48,7 @@
|
||||
<pattern>*/rss.do*</pattern>
|
||||
<pattern>*/SE2.2.1.O9186/*</pattern>
|
||||
<pattern>*/publish/*</pattern>
|
||||
<pattern>*/public/*</pattern>
|
||||
<pattern>*/pb/*</pattern>
|
||||
<pattern>*mageEditor*</pattern>
|
||||
|
||||
|
||||
@ -152,16 +152,32 @@ function excelFileChange(file) {
|
||||
fn_loadAddActive();
|
||||
var reader = new FileReader();
|
||||
var extension = file.name.split('.').pop().toLowerCase();
|
||||
reader.onload = function(e) {
|
||||
console.log('extension : ', extension);
|
||||
reader.onload = function (e) {
|
||||
setTimeout(() => { // 파일 읽기 완료 후 실행되도록 함
|
||||
if (extension === 'xlsx') {
|
||||
var data = new Uint8Array(e.target.result);
|
||||
var workbook = XLSX.read(data, {type: 'array'});
|
||||
var workbook = XLSX.read(data, { type: 'array' });
|
||||
var firstSheet = workbook.Sheets[workbook.SheetNames[0]];
|
||||
var jsonData = XLSX.utils.sheet_to_json(firstSheet, {header: 1});
|
||||
var jsonData = XLSX.utils.sheet_to_json(firstSheet, { header: 1 });
|
||||
console.log('xlsx jsonData : ', jsonData);
|
||||
processExcelData(jsonData);
|
||||
} else if (extension === 'xls') {
|
||||
console.log('xls extension detected');
|
||||
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 });
|
||||
console.log('xls jsonData : ', jsonData);
|
||||
|
||||
// 문제 데이터를 확인하는 함수 호출
|
||||
findInvalidDBCharacters(jsonData);
|
||||
|
||||
|
||||
processExcelData(jsonData);
|
||||
} else if (extension === 'txt') {
|
||||
var textData = e.target.result;
|
||||
console.log('txt data : ', textData);
|
||||
processTextData(textData);
|
||||
} else {
|
||||
alert('지원되지 않는 파일 형식입니다.');
|
||||
@ -171,14 +187,40 @@ 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);
|
||||
} else {
|
||||
alert('지원되지 않는 파일 형식입니다.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//문제 데이터를 확인하는 함수
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 엑셀 데이터 처리 함수
|
||||
function processExcelData(data) {
|
||||
console.log('processExcelData: ', processExcelData);
|
||||
var keys = ['A', 'B', 'C', 'D', 'E', 'F', 'G'];
|
||||
var tableData = [];
|
||||
var totalRows = data.length - 2; // 전체 데이터 수 (1, 2행 제외)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user