중앙탑고등학교 로고이미지

RSS 페이스북 공유하기 트위터 공유하기 카카오톡 공유하기 카카오스토리 공유하기 네이버밴드 공유하기 프린트하기
test
작성자 중앙탑고 등록일 25.05.15 조회수 3

<!DOCTYPE html>

<html>

<head>

  <meta charset="utf-8">

  <title>학번 조회 시스템</title>

  <script src="https://cdn.sheetjs.com/xlsx-0.20.0/package/dist/xlsx.full.min.js"></script>

  <style>

    body { font-family: sans-serif; margin: 30px; }

    input, button { padding: 8px; margin: 5px; font-size: 14px; }

  </style>

</head>

<body>

  <h2>엑셀 파일 업로드 기반 학번 조회</h2>

  <input type="file" id="fileInput" accept=".xlsx" />

  <br><br>

  <label>이름:</label>

  <input type="text" id="nameInput" />

  <label>생년월일 (yyyy-mm-dd):</label>

  <input type="text" id="birthInput" />

  <button onclick="findStudentId()">학번 조회</button>

 

  <p id="result"></p>

 

  <script>

    let studentData = [];

 

    document.getElementById('fileInput').addEventListener('change', function(e) {

      const file = e.target.files[0];

      const reader = new FileReader();

      reader.onload = function(e) {

        const data = new Uint8Array(e.target.result);

        const workbook = XLSX.read(data, { type: 'array' });

        const sheetName = workbook.SheetNames[0];

        const worksheet = workbook.Sheets[sheetName];

        studentData = XLSX.utils.sheet_to_json(worksheet);

        alert("엑셀 파일이 성공적으로 로드되었습니다.");

      };

      reader.readAsArrayBuffer(file);

    });

 

    function findStudentId() {

      const name = document.getElementById("nameInput").value.trim();

      const birth = document.getElementById("birthInput").value.trim();

      const result = document.getElementById("result");

 

      if (!studentData.length) {

        result.textContent = "먼저 엑셀 파일을 업로드하세요.";

        return;

      }

 

      const found = studentData.find(row => {

        return row["이름"] === name && String(row["생년월일"]).slice(0, 10) === birth;

      });

 

      if (found) {

        result.textContent = `조회된 학번: ${found["학번"]}`;

      } else {

        result.textContent = "일치하는 정보가 없습니다.";

      }

    }

  </script>

</body>

</html>


다음글 2025. 중앙탑고등학교 수학교육 운영 계획서