Server IP : 162.240.98.243 / Your IP : 3.145.42.9 Web Server : Apache System : Linux server.bti.yaw.mybluehostin.me 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : btiyawmy ( 1003) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/btiyawmy/public_html/login.easenup.in/ |
Upload File : |
function exportData(){ /* Get the HTML data using Element by Id */ var table = document.getElementById("tblStocks"); /* Declaring array variable */ var rows =[]; //iterate through rows of table for(var i=0,row; row = table.rows[i];i++){ //rows would be accessed using the "row" variable assigned in the for loop //Get each cell value/column from the row column1 = row.cells[0].innerText; column2 = row.cells[1].innerText; column3 = row.cells[2].innerText; column4 = row.cells[3].innerText; column5 = row.cells[4].innerText; /* add a new records in the array */ rows.push( [ column1, column2, column3, column4, column5 ] ); } csvContent = "data:text/csv;charset=utf-8,"; /* add the column delimiter as comma(,) and each row splitted by new line character (\n) */ rows.forEach(function(rowArray){ row = rowArray.join(","); csvContent += row + "\r\n"; }); /* create a hidden <a> DOM node and set its download attribute */ var encodedUri = encodeURI(csvContent); var link = document.createElement("a"); link.setAttribute("href", encodedUri); link.setAttribute("download", "Stock_Price_Report.csv"); document.body.appendChild(link); /* download the data file named "Stock_Price_Report.csv" */ link.click(); }