我在变量中获取整个 Excel 数据,excelRows此时我只想将“SRNO”列的第 1 个值获取到文本框
function Upload() {
//Reference the FileUpload element.
var fileUpload = document.getElementById("ExcelFile");
//Validate whether File is valid Excel file.
var regex = /^([a-zA-Z0-9\s_\\.\-:])+(.xls|.xlsx)$/;
if (regex.test(fileUpload.value.toLowerCase())) {
if (typeof (FileReader) != "undefined") {
var reader = new FileReader();
reader.onload = function (e) {
FillRow(e.target.result);
};
reader.readAsBinaryString(fileUpload.files[0]);
reader.readAsArrayBuffer(fileUpload.files[0]);
}
else {
alert("This browser does not support HTML5.");
}
} else {
alert("Please upload a valid Excel file.");
}
};
function FillRow(data) {
var workbook = XLSX.read(data, {
type: 'binary'
});
var sel_val = document.getElementById("ddlSheetName").value;
var excelRows = XLSX.utils.sheet_to_row_object_array(workbook.Sheets[sel_val]);
for (var j = 0; j <= excelRows.length; j++) {
//how to fetch first value and last value of specific column
}
};
我是 Javascript 的新手,所以任何帮助将不胜感激。
相关分类