Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form id="formexcel" action="" method="post" name="formexcel">
- <input type="hidden" name="exceldata" id="exceldata" value="" />
- </form>
- function exportDivToExcel() {
- document.formexcel.exceldata.value=$('#htmlbody').html();
- $("#lblReportForPrint").html("Procurement operation review report");
- document.formstyle.method='POST';
- document.formstyle.action='${pageContext.servletContext.contextPath}/generateexcel';
- document.formstyle.submit();
- }
- StringBuilder exceldata = new StringBuilder();
- exceldata.append(request.getParameter("exceldata"));
- ServletOutputStream outputStream = response.getOutputStream();
- response.setContentType("application/vnd.ms-excel");
- response.setCharacterEncoding("UTF-8");
- response.setHeader("Content-Disposition", "attachment;filename="exportexcel.xls"");
- outputStream.write(exceldata.toString().getBytes());
- var resultFromTable2CSV = $('#table-id').table2CSV({delivery:'value'});
- var blob = new Blob([resultFromTable2CSV], {type: "text/csv;charset=utf-8"});
- saveAs(blob, 'desiredFileName.csv');
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
- <script src="dist/jquery.table2excel.min.js"></script>
- $("#yourHtmTable").table2excel({
- exclude: ".excludeThisClass",
- name: "Worksheet Name",
- filename: "SomeFile" //do not include extension
- });
- $("button").click(function(){
- $("#table2excel").table2excel({
- // exclude CSS class
- exclude: ".noExl",
- name: "Excel Document Name"
- });
- });
Add Comment
Please, Sign In to add comment