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.?
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.
Ping & DNS - updated with new look and Ping home screen widget
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.
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.
Joined: Apr 27, 2010
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.
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.
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.
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.