Add validation for uploaded file data format

This commit is contained in:
2025-12-31 15:38:32 +09:00
parent 20eb3a0e81
commit 108b78bf64

View File

@@ -29,6 +29,21 @@ function App() {
const sheetName = workbook.SheetNames[0]; const sheetName = workbook.SheetNames[0];
const worksheet = workbook.Sheets[sheetName]; const worksheet = workbook.Sheets[sheetName];
const jsonData = utils.sheet_to_json(worksheet, {raw:true}); const jsonData = utils.sheet_to_json(worksheet, {raw:true});
if (jsonData.length === 0) {
alert("파일에 데이터가 없습니다.");
return;
}
const columns = Object.keys(jsonData[0]);
const requiredColumns = ['address', 'amount'];
if (columns.length !== 2 ||
!requiredColumns.every(col => columns.includes(col))) {
alert("양식이 맞지 않습니다.");
return;
}
let total = totalAmount; let total = totalAmount;
const filteredData = jsonData.filter(row => { const filteredData = jsonData.filter(row => {