ITeye博客

csv生成

highfly-s · 2015-06-19 19:29 · WEB前端 · Web前端 · Markdown

  1. <head>
  2. <meta http-equiv="content-type" content="text/html; charset=gb2312">
  3. <meta name="author" content="oscar999">
  4. <title>
  5. </title>
  6. <script>
  7. function clickDownload(aLink)
  8. {
  9. var str = "栏位1,栏位2,栏位3\n值1,值2,值3";
  10. str =  encodeURIComponent(str);
  11. aLink.href = "data:text/csv;charset=utf-8,\ufeff"+str;
  12. aLink.click();
  13. }
  14. </script>
  15. </head>
  16. <body>
  17. <a id="test" onclick="clickDownload(this)" download="downlaod.csv" href="#">download</a>
  18. </body>
  19. </html>

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。