Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

display csv file as an excel in java

 
Dhivya Krishnan
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.,

On a button click,I want to read the contents of a csv file inside a directory and open the same contents as an excel file.
I am able to read the contents in a csv file, but can some one help me in displaying it in an excel format.?
 
Swastik Dey
Rancher
Posts: 1604
5
Android Java Java ME
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dhivya Krishnan wrote:displaying it in an excel format.?

What does that mean? There are any number of ways of displaying a spreadsheet, including mimicking the way Excel would. Are you asking how to do that in a Java app? If so, POI plays no role in that. If you meant something else, please elaborate.
 
Rob Spoor
Sheriff
Pie
Posts: 20526
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about a simple JTable?
 
Dhivya Krishnan
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the link swastik., but that was not what i was searching for.
I have to read a csv file from some location for a particular date and its contents must be displayed to the user. This must happen on a button click. The contents must be displayed in an excel sheet.
 
Swastik Dey
Rancher
Posts: 1604
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean it's a web application?
 
Swastik Dey
Rancher
Posts: 1604
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More over your query is not very clear. Even if its a standalone java app, do you wish to display the data just in excel format(i.e just a tabular representation), if so as suggested in one of the above posts JTable should be good enough, and if you wish to display the data in excel sheet itself, you probably need POI, and you should get some help regarding this from the link I have referred.
 
Dhivya Krishnan
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Swastik,since i am new to this concept i am not able to explain it clearly. Let me try it once again.
My requirement is i need to open an excel file on a button click., the data to this excel file must come a .csv file.
In the link which you gave., it is the other way converting excel file to .csv.
 
Swastik Dey
Rancher
Posts: 1604
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dhivya,
Button click on a desktop app or web app? I pretend this to be a desktop app, and if that is the case if you look at timesheet demo example, they are using String arrays to create the values in excel sheet, in your case only difference is instead of string array you have the data from a csv file.
 
Dhivya Krishnan
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its a web application
 
Swastik Dey
Rancher
Posts: 1604
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, so the scenario is somewhat like this, correct me if I am wrong. User gets a web page. He/she clicks on a button, request goes to server. At the server side you open a csv file file, process it and send the contents back to the client, which is displayed in client's browser in excel sheet.
 
Dhivya Krishnan
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes you are correct..
 
Rob Spoor
Sheriff
Pie
Posts: 20526
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has nothing to do with Swing, AWT, SWT or JFace.

You're going to need a servlet that outputs the Excel file, using the right content type and disposition. You call this servlet from your button. If all is set up correctly you will then get a popup asking the user to open or save the file.

I'll move this thread to our Servlets forum.
 
Swastik Dey
Rancher
Posts: 1604
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, how far have you proceeded with the code?
 
Dhivya Krishnan
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am able to read the csv file data., i want to know as how to add it to an excel.
 
Dhivya Krishnan
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I am able to add it to an excel also now.. Now just need to work on displaying the excel.
Anyways thanks swastik for guiding.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic