I am trying to make a my index.js file read Excel file (.xlsx) and get data from it which I want to show on my website. It is not a server based though I am using some node modules. I have started learning JavaScript recently and wanted to make this thing. I want to require xlsx and work it in my normal website. (no server).
Here is my Code:
Home.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSS StyleSheet -->
<link rel="stylesheet" href="">
</head>
<body>
<h1>Hello there!</h1>
<p>Here Comes some Excel Data!</p>
<script src="index.js" async defer></script>
</body>
</html>
Index.js
import xlsx from 'xlsx';
const file = xlsx.readFile('./test.xlsx');
const sheets = file.SheetNames;
const jsonSheet = reader.utils.sheet_to_json(file.Sheets[sheets[0]]);
console.log(jsonSheet);
And there is a excel file call dataSheet.xlsx. Please fix this error and help me fetch data from excel sheets into my website. The xlsx module is a external module and not my own.