본문 바로가기

카테고리 없음

연습

반응형
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script lang="javascript" src="./dist/xlsx.full.min.js"></script>
</head>
<body>
<input type="file" />
<input type="button" value="클릭" onclick="hello()"/>
<input type="button" value="생성" onclick="excelwrite()"/>
</body>
<script>
function hello() {

var workbook = XLSX.read('out.xlsx');

console.log(XLSX.utils.sheet_to_json(workbook.Sheets['test'], {raw: true}));

}

function excelwrite() {
var wb = XLSX.utils.book_new();
wb.SheetNames.push("test");
var ws_data = [['hello', 'world']];
var ws = XLSX.utils.aoa_to_sheet(ws_data);
wb.Sheets["test"] = ws;
var about = XLSX.write(wb, {bookType:'xlsx', type:'binary'});
console.log(about);

XLSX.writeFile(wb, 'out.xlsx');
}
</script>
</html>


반응형