반응형
SheetJS의 Library를 활용한 예제입니다.
<!DOCTYPE html>
<html>
<head>
<title>Excel Read</title>
<script lang="javascript" src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.16.9/xlsx.full.min.js"></script>
</head>
<body>
<h1>Excel Read Example</h1>
<div>
<input type="file" id="inputExcelRead" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"/>
</div>
<div id="displayDiv">
</div>
</body>
<script>
var reader = new FileReader();
var excelFileData = null;
var inputElement = document.getElementById('inputExcelRead');
inputElement.addEventListener('change', function() {
console.log(event.target.files);
reader.readAsArrayBuffer(event.target.files[0]);
}, false);
reader.onload = function (e) {
var data = e.target.result;
var workbook = XLSX.read(data, { type: "array" });
var sheetName = workbook.SheetNames;
var sheet = workbook.Sheets[sheetName];
excelFileData = XLSX.utils.sheet_to_html(sheet);
var element = document.getElementById('displayDiv');
element.innerHTML = excelFileData;
};
</script>
</html>
반응형
'엉터리 개발 이야기' 카테고리의 다른 글
local CORS error (0) | 2021.11.17 |
---|---|
VSCode 에서 Python Flask 설정 (0) | 2021.11.08 |
[threejs] 연습-1 (0) | 2020.03.04 |
sequelize raw query 간헐적 동작 안함 (0) | 2019.08.26 |
chartjs new charts (0) | 2019.03.15 |