Guest User

Untitled

a guest
Aug 20th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. <form id="formexcel" action="" method="post" name="formexcel">
  2. <input type="hidden" name="exceldata" id="exceldata" value="" />
  3. </form>
  4.  
  5. function exportDivToExcel() {
  6. document.formexcel.exceldata.value=$('#htmlbody').html();
  7. $("#lblReportForPrint").html("Procurement operation review report");
  8. document.formstyle.method='POST';
  9. document.formstyle.action='${pageContext.servletContext.contextPath}/generateexcel';
  10. document.formstyle.submit();
  11. }
  12.  
  13. StringBuilder exceldata = new StringBuilder();
  14. exceldata.append(request.getParameter("exceldata"));
  15. ServletOutputStream outputStream = response.getOutputStream();
  16. response.setContentType("application/vnd.ms-excel");
  17. response.setCharacterEncoding("UTF-8");
  18. response.setHeader("Content-Disposition", "attachment;filename="exportexcel.xls"");
  19. outputStream.write(exceldata.toString().getBytes());
  20.  
  21. var resultFromTable2CSV = $('#table-id').table2CSV({delivery:'value'});
  22.  
  23. var blob = new Blob([resultFromTable2CSV], {type: "text/csv;charset=utf-8"});
  24.  
  25. saveAs(blob, 'desiredFileName.csv');
  26.  
  27. <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
  28.  
  29. <script src="dist/jquery.table2excel.min.js"></script>
  30.  
  31. $("#yourHtmTable").table2excel({
  32. exclude: ".excludeThisClass",
  33. name: "Worksheet Name",
  34. filename: "SomeFile" //do not include extension
  35. });
  36.  
  37. $("button").click(function(){
  38. $("#table2excel").table2excel({
  39. // exclude CSS class
  40. exclude: ".noExl",
  41. name: "Excel Document Name"
  42. });
  43. });
Add Comment
Please, Sign In to add comment