• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAVA AND EXCEL CHART

 
swami dorai
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to create some java program behind the webserver which will read some values from the DB based on the input. i then need to open an excel application dynamically to create an excel chart using those values. Is there a way for this.

Is there any freeware tools which I can make use of ?

thanks in advance
Swami
 
Damanjit Kaur
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use Apache POI API.
http://jakarta.apache.org/poi/
 
Nigel Browne
Ranch Hand
Posts: 703
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Damanjit Kaur:
You can use Apache POI API.
http://jakarta.apache.org/poi/


POI doesn't include support for excel charts at the moment.
 
swami dorai
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought the POI still does not support drawing charts on the excel. Correct me if I am wrong.

Thanks
 
Damanjit Kaur
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well , I just asked my colleauge who had given presentation on POI. As told by him,You can't create excel chart through java. but if you already have chart template in an excel file then modifying the data in the range will be refelcted in the chart.
 
swami dorai
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Damanjit,
Thanks for the info. Does this mean that I should have one template excel file(with chart template) for every report and update them with the data. Will this work over the web, ie, I have to put this logic somewhere on my servlet.

Has someone done this or is there any links to refer to.

Thanks a lot.
 
Damanjit Kaur
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes thats what I mean you need to create templates.

I don't know how to upload excel file with chart on web browser. However to upload the chart, may be first using POI you get access to chart range in excel file and then using jasper reports convert it to pdf file which can be then uploaded on web. Might be a bad idea but I don't know of other things.

http://jasperreports.sourceforge.net/

There is an excel jdbc driver too an alternative to POI/JIntegra.
https://xlsql.dev.java.net/
 
swami dorai
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the servlet, after I update the excel file with new data, there should be a way to send the file to the browser(maybe use redirect).

or if I set the content-type to excel, the below code might work ...

response.setContentType( "application/vnd.ms-excel ");
response.setHeader( "Content-Disposition ", "inline; filename=xlsFile.xls ");
out = new DataOutputStream(response.getOutputStream());
out.write(data.toByteArray());
out.flush();

Thanks for your time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic