首页 > 代码库 > js端table转csv

js端table转csv


index.jsp

function getCSVData(){

      //tablesorter就是要导出的table

       var csv_value=http://www.mamicode.com/$(‘#tablesorter‘).table2CSV({delivery:‘value‘});

       //$("#download_schedule").attr("href","./download_schedule.jsp?csv_value=http://www.mamicode.com/‘"+csv_value+"‘");

       $("#csv_text").val(csv_value); 

   }


<form  action="download_schedule.jsp" method ="post" target="_blank"> 

  <input type="hidden" name="csv_text" id="csv_text">

  <input type="submit" value="http://www.mamicode.com/csv出力" /></td>

</form>


download_schedule.jsp

<%@ page language="java" import="java.util.*,java.lang.*" pageEncoding="shift_jis"%>

 <% 

response.setHeader("Content-type","application/octet-stream;charset=shift_jis");

response.setHeader("Content-Disposition","attachment; filename=\"work table.csv\"");

String value = http://www.mamicode.com/request.getParameter("csv_text");

out.println(value);

%>


table2csv.js下载链接

http://download.csdn.net/detail/le5le/8385143


js端table转csv