The problem is I want a solution to convert excel file into an image, i.e., an application which should read an excel file (some range of cells) and save it as an image (jpeg, bmp). I am trying by using POI but it is not capturing the data in the image.
Well, if you've already got an API to extract data from Excel files, I'm assuming you've managed to get objects representing the spreadsheet, and the various cells and data it contains?
I suppose the next job is to build a rendering engine which lays all that data out onto a virtual "canvas", using java.awt and java.awt.geom to do some of the hard work, and then a converter which takes all the pixel data on that canvas and puts it in a java.awt.BufferedImage. You can then use the Image I/O API to export this into an image file.
So if you have both the importers for Excel files and exporters for images (exporters for common formats are supplied with the Image I/O API), then all you need is an engine which does the geometry and layout, then writes the data to the Graphics2D obtained from the BufferedImage's createGraphics() method. You need to be familiar with the elementary AWT graphics classes and have some familiarity with geometry, but it's certainly doable.
If you want a rough sketch of an approach, feel free to ask. [ March 17, 2006: Message edited by: Charles Lyons ]
Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / AmazonAmazon UK )
However if you were hoping for some Java code which duplicates the way that Excel lays out a spreadsheet when it displays it on your computer monitor, I am fairly certain that code does not exist. But as Charles suggests, you could certainly try it yourself.
To do this you can use Aspose lib. Aspose cells gives a wide range of api to perform actions on excel sheet. Here is a link where you found how to export excel sheet as png/jpeg images and also how to get the images of excel componnt too.