0

In our project we are having the requirement to export the JSP page into excel. We cannot use Apache POI or any other open source APIs. I came across the below mentioned simple way of doing

<%
response.setHeader("Content-Disposition", "attachment;filename=\"mult-table.xls\""); %> <%@ page contentType="application/vnd.ms-excel" %> <table><tr><td> using image src to load images </td></tr></table>

The excel is generated but the image is not shown in the excel. In our JSP pages we are having many images which should also get exported into excel along with other data.hanks

Please let me know how to do it.

Thanks Ravi

0

2 Answers 2

1

I use the complete URL in HTML image code, because when you download the excel, it's a text xls file, with format HTML, and the images embeddable and the absolute path, intead it can solve the image source. like this:

<%
// Java CODE
...
String url=request.getRequestURL().toString(); // URL base page
String imageUrl=url.substring(0,url.indexOf(request.getRequestURI()))+"/images/logo.gif"; // image absolute url
...

%>
...
<!-- HTML CODE -->
...
<img src="<%=imageUrl%>" width="198" height="36" /></th>
...
Sign up to request clarification or add additional context in comments.

Comments

0

As far as I know you can not insert an image in xls file, when this html xls

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.