Now, I am trying to let my JS program deal with Excel files(.xlsx). But, errors, as is written in Title above, get my way. I would ask you for help.
[HTML]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ENtoJP</title>
<link rel="stylesheet" href="enjp.css">
</head>
<body>
<div id="question">
<h2>Questions are here</h2>
</div>
<div class="button_1">
<button>Answer_1</button>
<button>Answer_2</button>
</div>
<div class="button_2">
<button>Answer_3</button>
<button>Answer_4</button>
</div>
<script src="words.js" type="module"></script>
</body>
</html>
UPDATED on 6/19 JST JS file
import xlsx from 'xlsx';
fetch("/Word_List_1.xlsx")
.then(response => response.arrayBuffer())
.then(data => {
let workbook = xlsx.read(data, { type: 'array' });
let sheets = workbook.SheetNames;
console.log(sheets);
let workSheet = workbook.Sheets['Sheet1'];
let range = workSheet['!ref'];
console.log('range = ' + range);
let itemA1 = workSheet['A1'];
console.log(itemA1);
})
.catch(error => {
console.error('An error occurred while reading the Excel file:', error);
});
Could you give me an idea to have my code work?
UPDATE on my USQ;
With your kind support, I changed the JS codes, but could not did it.
Here is an error from the Browser (MS EDGE).
And attached are pics of an Excel file and a vsc screen.
I would appreciate you if you could kindly give any idea to let the js file read an Excel file.