- < script type = "text/javascript" > function Upload() {
- var fileUpload = document.getElementById("fileUpload");
- var regex = /^([a-zA-Z0-9\s_\\.\-:])+(.csv|.txt)$/;
- if (regex.test(fileUpload.value.toLowerCase())) {
- if (typeof(FileReader) != "undefined") {
- var reader = new FileReader();
- reader.onload = function(e) {
- var table = document.createElement("table");
- var rows = e.target.result.split("\n");
- for (var i = 0; i < rows.length; i++) {
- var row = table.insertRow(-1);
- var cells = rows[i].split(",");
- for (var j = 0; j < cells.length; j++) {
- var cell = row.insertCell(-1);
- cell.innerHTML = cells[j];
- }
- }
- var dvCSV = document.getElementById("dvCSV");
- dvCSV.innerHTML = "";
- dvCSV.appendChild(table);
- }
- reader.readAsText(fileUpload.files[0]);
- } else {
- alert("This browser does not support HTML5.");
- }
- } else {
- alert("Please upload a valid CSV file.");
- }
- } < /script>
10 Aralık 2015 Perşembe
Read an Excel File with JavaScript (without ActiveXObject)
Kaydol:
Kayıt Yorumları (Atom)
Hiç yorum yok:
Yorum Gönder