Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Inserting Image In Excel Sheet Using JSP 
 

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.

 

                         

» View all related tutorials
Related Tags: java c excel apache script import model setup io client method user print arguments type ip port sets anchor cli

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

2 comments so far (
post your own) View All Comments Latest 10 Comments:

iam specifying like this

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


<table><tr><td><img src="/projectname/resources/images/executive.jpg" ></td></tr></table>

But when i open an excel ,the image is not appearing,but shows a X mark in red color.

Posted by sujatha on Thursday, 11.15.07 @ 16:39pm | #37491

this is not possible to insert image into excel sheet.

i am using xslt stylesheet to create excel report. i used this code in my stylesheet but it is not accepting table row and table data columns. in that row it doesn't return any value.
how can i insert an image into excel using xslt.

thanks
raja

Posted by raja on Friday, 06.22.07 @ 20:01pm | #19978

Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.