html
<!DOCTYPE html>
<html>
<head>
<title>ابحث عن الطالب</title>
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js"></script>
</head>
<body>
<input type="file" id="fileInput">
<button onclick="searchStudent()">ابحث عن الطالب</button>
<div id="studentData"></div>
<script>
function searchStudent() {
var studentId = "excel-File.xlsx";// رقم القيد
var fileInput = document.getElementById('fileInput');
var file = fileInput.files[0];
var reader = new FileReader();
reader.onload = function(e) {
var data = new Uint8Array(e.target.result);
var workbook = XLSX.read(data, { type: 'array' });
var worksheet = workbook.Sheets[workbook.SheetNames[0]];
var jsonData = XLSX.utils.sheet_to_json(worksheet, { header: 1 });
var studentData = jsonData.filter(function(row) {
return row[0] === studentId;
});
if (studentData.length > 0) {
var studentInfo = studentData[0];
var studentDataElement = document.getElementById('studentData');
studentDataElement.innerHTML = 'اسم الطالب: ' + studentInfo[1] + '<br>الحاسوب: ' + studentInfo[2];
} else {
console.log('لم يتم العثور على بيانات;');
}
};
reader.readAsArrayBuffer(file);
}
</script>
</body>
</html>