Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Import data from Excel and Print in Servlet

 
Aniketh Narayanan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am currently working on a project where i have to import data stored in excel sheet and print it as an output using Servlets.

I am using the POI library for exporting data. But I also need to import.

I have no idea how to write the code.

Please help.

Thanks.
 
Niraj Jha
Ranch Hand
Posts: 63
Java Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check documentation:
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Niraj Jha wrote:Check documentation:

Why do you recommend the low level API? POI has perfectly fine high level APIs.

But let's take a step back: You said you need to import data from Excel, and then print it. So what do you mean by "I am using the POI library for exporting data." - what is the "export" step that you already have?

But regardless, the POI web site has many, many code examples for doing just about anything related to XLS and XLSX files.
 
Aniketh Narayanan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:
Niraj Jha wrote:Check documentation:

Why do you recommend the low level API? POI has perfectly fine high level APIs.

But let's take a step back: You said you need to import data from Excel, and then print it. So what do you mean by "I am using the POI library for exporting data." - what is the "export" step that you already have?

But regardless, the POI web site has many, many code examples for doing just about anything related to XLS and XLSX files.




There was a part in the project which required acquiring data from the database and exporting it in excel sheets.
That is where i used the POI library for exporting.

But now i want to import data from excel and print it.

Can you help me with the code ???
 
T Mishra
Ranch Hand
Posts: 108
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This should help you
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I said, the POI site has tons of examples for doing just about anything involving Excel files; have you looked through the "Quick Guide" and "HOWTO" pages?
 
Aniketh Narayanan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
T Mishra wrote:This should help you



Thanks, it works like a charm...


thanks a lot
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Be aware that that code only works for XLS files, not XLSX files. If you want something that works for both files, you should use the org.apache.poi.ss.... packages instead of the org.apachepoi.hssf... packages; the code shouldn't be hard to refactor.
 
Aniketh Narayanan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Be aware that that code only works for XLS files, not XLSX files. If you want something that works for both files, you should use the org.apache.poi.ss.... packages instead of the org.apachepoi.hssf... packages; the code shouldn't be hard to refactor.



Oh okk. I didnt test it with a XLSX file. I shall refactor the code .

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic