Hi,
I have a jsp(original page), which has a link "Print as Excel" (sounds stupid - but i HAVE to be able to print it as excel). When the user clicks on this link, an almost invisible (zero height and width)popup window should open which opens the original page contents but with:
response.setContentType("application/vnd.ms-excel"), and prints the excel sheet and closes by itself.
I am able to pop a small window, but as the response type is set to Excel it opens MS Excel WorkBook- which is very big and visible. And the window.print() is not printing the Excel sheet, instead its simply printing the pop-window itself and window.close() is closing the pop-up window, but not the Excel WorkBook.
My Code
Can anyone help me with this ?
1. I want to open a very small Excel WorkBook(almost invisible to user)
2. printAndClose() method should print Excel sheet instead of the popup window.
3. Excel workbook should close by itself after printing.
Please Help. Thanks a bunch.
I have a jsp(original page), which has a link "Print as Excel" (sounds stupid - but i HAVE to be able to print it as excel). When the user clicks on this link, an almost invisible (zero height and width)popup window should open which opens the original page contents but with:
response.setContentType("application/vnd.ms-excel"), and prints the excel sheet and closes by itself.
I am able to pop a small window, but as the response type is set to Excel it opens MS Excel WorkBook- which is very big and visible. And the window.print() is not printing the Excel sheet, instead its simply printing the pop-window itself and window.close() is closing the pop-up window, but not the Excel WorkBook.
My Code
Code:
<%response.setContentType("application/vnd.ms-excel");%>
<%@ include file="/jsp/ivpLocks/originalPage.jsp" %>
<html>
<head>
<script type="JavaScript">
function printAndClose() {
window.print();
window.close();
}
</script>
</head>
<body onload="javascript: printAndClose();">
</body>
</html>
Can anyone help me with this ?
1. I want to open a very small Excel WorkBook(almost invisible to user)
2. printAndClose() method should print Excel sheet instead of the popup window.
3. Excel workbook should close by itself after printing.
Please Help. Thanks a bunch.