Home Jsp Poi Inserting Image In Excel Sheet Using JSP
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Inserting Image In Excel Sheet Using JSP

Advertisement
In this example, we create excel sheet and display image on that.

Inserting Image In Excel Sheet Using JSP

     

In this example, we create excel sheet and display image on that. We can request that the browser open the results in Excel and suggest the file to use when the user saves the file by setting the following two response headers: Content-Type and Content-Disposition

Here, we use page directive and set the contentType attribute by the value "application/vnd.ms-excel". The purpose of setting this contentType is to display the output in excel format.

<%@ page contentType="application/vnd.ms-excel" %> 

We set the header as: response.setHeader("Content-Disposition", "attachment; filename=\"mult-table.xls\"").The response object provides a convenience method for setting the Content-Type header. Both can be set with the setHeader method.

In this example we insert the image and the output will display in excel format with image.You can use third party APIs to create the excel sheet, which you can learn in our next example. The third party APIs are provided by Jakarta Apache Foundation group.

 The code of the program is given below:


<% response.setHeader("Content-Disposition""attachment; 
filename=\"mult-table.xls\""
); %>
<%page contentType="application/vnd.ms-excel" %>


<table><tr><td><img src="/excel/images.jpg" ></td></tr></table>

The output of the program is given below:

Download this example.

Advertisement

Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: May 19, 2007

Ask Questions?    Discuss: Inserting Image In Excel Sheet Using JSP   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
sharan
January 31, 2013
how to insert photo in execl sheet using jsp code

<% response.setHeader("Content-Disposition", "attachment; filename=\"mult-table.xls\""); %> <%@ page contentType="application/vnd.ms-excel" %> <table><tr><td><img src="/excel/images.jpg" ></td></tr></table> iam using this code but only sheet is generating butphoto is not displaying
sharan
January 31, 2013
how to insert photo in execl sheet using jsp code

<% response.setHeader("Content-Disposition", "attachment; filename=\"mult-table.xls\""); %> <%@ page contentType="application/vnd.ms-excel" %> <table><tr><td><img src="/excel/images.jpg" ></td></tr></table> iam trying with this code only sheet is genrating but image is not coming
Jerry
August 3, 2012
Insert image in excel using JSP - Not working

My image doesnot get displayed. Help!
DMCA.com