Server IP : 108.163.255.210 / Your IP : 18.226.34.148 Web Server : Apache System : Linux blossom.urlnameserver.com 3.10.0-1160.80.1.el7.x86_64 #1 SMP Tue Nov 8 15:48:59 UTC 2022 x86_64 User : ( 1172) PHP Version : 7.2.34 Disable Function : eval,escapeshellarg,proc_close,proc_get_status,proc_nice,proc_open,symlink,system,pcntl_exec,getrusage,chown,chgp,closelog,openlog,syslog,define_syslog_variables,php_ini_loaded_file,getservbyname,getservbyport,posix_getgid,posix_getgrgid,proc_terminate,pfsockopen,apache_child_terminate,posix_mkfifo,posix_setpgid,posix_setuid,hypot,pg_host,pos,posix_access,posix_getcwd,posix_getservbyname,myshellexec,getpid,posix_getsid,posix_isatty,posix_kill,posix_mknod,posix_setgid,posix_setsid,posix_setuid,posix_times,posix_uname,ps_fill,posix_getpwuid,global,ini_restore,zip_open,zip_read,rar_open,bzopen,bzread,bzwrite,apache_get_modules,apache_get_version,phpversionphpinfo,php_ini_scanned_files,get_current_user,disk_total_space,diskfreespace,leak,imap_list,hypo,filedump,safe_mode,getmygid,apache_getenv,apache_setenv,bzread,bzwrite,bzopen,phpini,higlight_file,dos_conv,get_cwd,er_log,cmd,e_name,vdir,get_dir,only_read,ftok,ftpexec,posix_getpwnam,mysql_list_dbs,disk_free_space,session_save_path,confirm_phpdoc_compiled,zip_entry_rea,php_u,psockopen,crack_opendict,crack_getlastmessage,crack_closedict,crack_check,fpassthru,posix_get_last_error,posix_getlogin,posix_getgroups,posix_strerror,posix_getrlimit,posix_getpgrp,posix_getgrnam,pos,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/unilinki/www/payroll/admin/ |
Upload File : |
<!DOCTYPE> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="author" content="Adila Faruk"> <title>Exporting Data to a CSV File</title> <style type="text/css"> body{ font-family: sans-serif; font-weight:300; padding-top:30px; color:#666; } .container{ text-align:center; } a{ color:#1C2045; font-weight:350;} table{ font-weight:300; margin:0px auto; border: 1px solid #1C2045; padding:5px; color:#666; } th,td{ border-bottom: 1px solid #dddddd; text-align:center; margin: 10px; padding:0 10px; } hr{ border:0; border-top: 1px solid #E7C254; margin:20px auto; width:50%; } .button{ background-color:#1C2045; color:#E7C254; padding:5px 20px; max-width: 300px; line-height:1.5em; text-align:center; margin:5px auto; } .button a{ color:#E7C254;} .refs{ display:block; margin:auto; text-align:left; max-width:500px; } .refs .label{ font-size:1.4em;} .refs > ul{ margin-top:10px; line-height:1.5em;} </style> </head> <body> <div class='container'> <div id="dvData"> <table> <tr> <th>Column One</th> <th>Column Two</th> <th>Column Three</th> </tr> <tr> <td>Row 1 Col 1</td> <td>Row 1 Col 2</td> <td>Row 1 Col 3 </td> </tr> <tr> <td>Row 2 Col 1</td> <td>Row 2 Col 2</td> <td>Row 2 Col 3</td> </tr> <tr> <td>Row 3 Col 1</td> <td>Row 3 Col 2</td> <td>Row 3 Col 3</td> </tr> </table> </div> <br/> <div class='button'> <a href="#" id ="export" role='button'>Save CSV </a> </div> </div> </div> <!-- Scripts ----------------------------------------------------------- --> <script type='text/javascript' src='https://code.jquery.com/jquery-1.11.0.min.js'></script> <!-- If you want to use jquery 2+: https://code.jquery.com/jquery-2.1.0.min.js --> <script type='text/javascript'> $(document).ready(function () { console.log("HELLO") function exportTableToCSV($table, filename) { var $headers = $table.find('tr:has(th)') ,$rows = $table.find('tr:has(td)') // Temporary delimiter characters unlikely to be typed by keyboard // This is to avoid accidentally splitting the actual contents ,tmpColDelim = String.fromCharCode(11) // vertical tab character ,tmpRowDelim = String.fromCharCode(0) // null character // actual delimiter characters for CSV format ,colDelim = '","' ,rowDelim = '"\r\n"'; // Grab text from table into CSV formatted string var csv = '"'; csv += formatRows($headers.map(grabRow)); csv += rowDelim; csv += formatRows($rows.map(grabRow)) + '"'; // Data URI var csvData = 'data:application/csv;charset=utf-8,' + encodeURIComponent(csv); $(this) .attr({ 'download': filename ,'href': csvData //,'target' : '_blank' //if you want it to open in a new window }); //------------------------------------------------------------ // Helper Functions //------------------------------------------------------------ // Format the output so it has the appropriate delimiters function formatRows(rows){ return rows.get().join(tmpRowDelim) .split(tmpRowDelim).join(rowDelim) .split(tmpColDelim).join(colDelim); } // Grab and format a row from the table function grabRow(i,row){ var $row = $(row); //for some reason $cols = $row.find('td') || $row.find('th') won't work... var $cols = $row.find('td'); if(!$cols.length) $cols = $row.find('th'); return $cols.map(grabCol) .get().join(tmpColDelim); } // Grab and format a column from the table function grabCol(j,col){ var $col = $(col), $text = $col.text(); return $text.replace('"', '""'); // escape double quotes } } // This must be a hyperlink $("#export").click(function (event) { // var outputFile = 'export' var outputFile = window.prompt("What do you want to name your output file (Note: This won't have any effect on Safari)") || 'export'; outputFile = outputFile.replace('.csv','') + '.csv' // CSV exportTableToCSV.apply(this, [$('#dvData>table'), outputFile]); // IF CSV, don't do event.preventDefault() or return false // We actually need this to be a typical hyperlink }); }); </script> </body> </html>