csv生成
highfly-s
· 2015-06-19 19:29 · WEB前端 · Web前端
· Markdown
- <head>
- <meta http-equiv="content-type" content="text/html; charset=gb2312">
- <meta name="author" content="oscar999">
- <title>
- </title>
- <script>
- function clickDownload(aLink)
- {
- var str = "栏位1,栏位2,栏位3\n值1,值2,值3";
- str = encodeURIComponent(str);
- aLink.href = "data:text/csv;charset=utf-8,\ufeff"+str;
- aLink.click();
- }
- </script>
- </head>
- <body>
- <a id="test" onclick="clickDownload(this)" download="downlaod.csv" href="#">download</a>
- </body>
- </html>