用Javascript读取Excel文件



我想在excel中每次只读取一行。我可以在excel中读取所有数据,但我不能限制它。要么我只能读取所有行的1列,要么读取所有数据。我怎么能读只有一行的javascript?

我使用这个脚本和这个src:

<script src="https://unpkg.com/read-excel-file@4.x/bundle/read-excel-file.min.js"></script>
<body>
<input type="file" id="input">
<script>
var input = document.getElementById('input');
input.addEventListener("change", function (){
readXlsxFile(input.files[0]).then(function (data){
data.map((row,index)=>{
var location= document.createTextNode(row);
console.log(location)

如果您需要一行,请不要在整个文件中添加map:

readXlsxFile(input.files[0]).then(data => {
console.log(data[0]) // supposed to print the first row
})

最新更新