Last active
May 29, 2017 18:24
-
-
Save nimahkh/3924a61dfc58119d9d51cc4c88790081 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | |
<script> | |
$(document).ready(function(){function t(t,n){var e=t.find("tr:has(td)"),o=String.fromCharCode(11),a=String.fromCharCode(0),r='"'+e.map(function(t,n){return $(n).find("td").map(function(t,n){return $(n).text().replace(/"/g,'""')}).get().join(o)}).get().join(a).split(a).join('"\r\n"').split(o).join('","')+'"';if(window.Blob&&window.URL){var i=new Blob([r],{type:"text/csv;charset=utf-8"}),c=URL.createObjectURL(i);$(this).attr({download:n,href:c})}else{var d="data:application/csv;charset=utf-8,"+encodeURIComponent(r);$(this).attr({download:n,href:d,target:"_blank"})}}$(".export").on("click",function(n){var e=[$("#dvData>table"),"export.csv"];t.apply(this,e)})}); | |
</script> | |
<style> | |
a.export, | |
a.export:visited { | |
display: inline-block; | |
text-decoration: none; | |
color: #000; | |
background-color: #ddd; | |
border: 1px solid #ccc; | |
padding: 8px; | |
} | |
table a:link { | |
color: #666; | |
font-weight: bold; | |
text-decoration:none; | |
} | |
table a:visited { | |
color: #999999; | |
font-weight:bold; | |
text-decoration:none; | |
} | |
table a:active, | |
table a:hover { | |
color: #bd5a35; | |
text-decoration:underline; | |
} | |
table { | |
font-family:Arial, Helvetica, sans-serif; | |
color:#666; | |
font-size:12px; | |
text-shadow: 1px 1px 0px #fff; | |
background:#eaebec; | |
margin:20px; | |
border:#ccc 1px solid; | |
-moz-border-radius:3px; | |
-webkit-border-radius:3px; | |
border-radius:3px; | |
-moz-box-shadow: 0 1px 2px #d1d1d1; | |
-webkit-box-shadow: 0 1px 2px #d1d1d1; | |
box-shadow: 0 1px 2px #d1d1d1; | |
} | |
table th { | |
padding:21px 25px 22px 25px; | |
border-top:1px solid #fafafa; | |
border-bottom:1px solid #e0e0e0; | |
background: #ededed; | |
background: -webkit-gradient(linear, left top, left bottom, from(#ededed), to(#ebebeb)); | |
background: -moz-linear-gradient(top, #ededed, #ebebeb); | |
} | |
table th:first-child { | |
text-align: left; | |
padding-left:20px; | |
} | |
table tr:first-child th:first-child { | |
-moz-border-radius-topleft:3px; | |
-webkit-border-top-left-radius:3px; | |
border-top-left-radius:3px; | |
} | |
table tr:first-child th:last-child { | |
-moz-border-radius-topright:3px; | |
-webkit-border-top-right-radius:3px; | |
border-top-right-radius:3px; | |
} | |
table tr { | |
text-align: center; | |
padding-left:20px; | |
} | |
table td:first-child { | |
text-align: left; | |
padding-left:20px; | |
border-left: 0; | |
} | |
table td { | |
padding:18px; | |
border-top: 1px solid #ffffff; | |
border-bottom:1px solid #e0e0e0; | |
border-left: 1px solid #e0e0e0; | |
background: #fafafa; | |
background: -webkit-gradient(linear, left top, left bottom, from(#fbfbfb), to(#fafafa)); | |
background: -moz-linear-gradient(top, #fbfbfb, #fafafa); | |
} | |
table tr.even td { | |
background: #f6f6f6; | |
background: -webkit-gradient(linear, left top, left bottom, from(#f8f8f8), to(#f6f6f6)); | |
background: -moz-linear-gradient(top, #f8f8f8, #f6f6f6); | |
} | |
table tr:last-child td { | |
border-bottom:0; | |
} | |
table tr:last-child td:first-child { | |
-moz-border-radius-bottomleft:3px; | |
-webkit-border-bottom-left-radius:3px; | |
border-bottom-left-radius:3px; | |
} | |
table tr:last-child td:last-child { | |
-moz-border-radius-bottomright:3px; | |
-webkit-border-bottom-right-radius:3px; | |
border-bottom-right-radius:3px; | |
} | |
table tr:hover td { | |
background: #f2f2f2; | |
background: -webkit-gradient(linear, left top, left bottom, from(#f2f2f2), to(#f0f0f0)); | |
background: -moz-linear-gradient(top, #f2f2f2, #f0f0f0); | |
} | |
</style> | |
<a href="#" class="export">Export To CSV</a> | |
<div id="dvData"> | |
<table> | |
<tr> | |
<th>Column One</th> | |
<th>Column Two</th> | |
<th>Column Three</th> | |
</tr> | |
<tr> | |
<td>row1 Col1</td> | |
<td>row1 Col2</td> | |
<td>row1 Col3</td> | |
</tr> | |
<tr> | |
<td>row2 Col1</td> | |
<td>row2 Col2</td> | |
<td>row2 Col3</td> | |
</tr> | |
<tr> | |
<td>row3 Col1</td> | |
<td>row3 Col2</td> | |
<td>row3 Col3</td> | |
</tr> | |
<tr> | |
<td>row4 'Col1'</td> | |
<td>row4 'Col2'</td> | |
<td>row4 'Col3'</td> | |
</tr> | |
<tr> | |
<td>row5 "Col1"</td> | |
<td>row5 "Col2"</td> | |
<td>row5 "Col3"</td> | |
</tr> | |
<tr> | |
<td>row6 "Col1"</td> | |
<td>row6 "Col2"</td> | |
<td>row6 "Col3"</td> | |
</tr> | |
</table> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment