TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Bhavleen Singh
NA
203
5.2k
To get No.of Excel sheet records in textbox using javascript
Jul 15 2019 1:19 AM
I want to get excel file starting data and ending data on textboxes named "start_row" and "end_row"
to fetch all the records excel data I used javascript function given below :
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();
debugger
//For Browsers other than IE.
if (reader.readAsBinaryString) {
reader.onload = function (e) {
FillRow(e.target.result);
};
reader.readAsBinaryString(fileUpload.files[0]);
} else {
//For IE Browser.
reader.onload = function (e) {
var data = "";
var bytes = new Uint8Array(e.target.result);
for (var i = 0; i < bytes.byteLength; i++) {
data += String.fromCharCode(bytes[i]);
}
};
reader.readAsArrayBuffer(fileUpload.files[0]);
}
} else {
alert("This browser does not support HTML5.");
}
} else {
alert("Please upload a valid Excel file.");
}
};
function FillRow(data) {
debugger
var workbook = XLSX.read(data, {
type: 'binary'
});
var sel_val = document.getElementById("ddlSheetName").value;
var txt_start_row = document.getElementById("start_row");
var txt_end_row = document.getElementById("end_row");
var excelRows = XLSX.utils.sheet_to_row_object_array(workbook.Sheets[sel_val]);
}
In var excelRows there is array consists of all rows on workbook, as declared i want starting row no. on txt_start_row and ending row no. on txt_end_row
can anyone help!
Reply
Answers (
1
)
WordPress Plugin
Facebook news feed