• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to open exported excel from jtable  RSS feed

 
shikhaj jainy
Ranch Hand
Posts: 35
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am using

HssfTableUtils.exportToSheet method to export jtable to an excel file at some physical location.In some scenarios, I want to open this excel directly (without saving and then opening). Please let me know if there are some apis and how can i achieve this without saving.


Thanks.
 
salvin francis
Bartender
Posts: 1479
21
Eclipse IDE Google Web Toolkit Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your solution is here : http://www.coderanch.com/t/446476/java/java/open-excel-file-java-program

 
shikhaj jainy
Ranch Hand
Posts: 35
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Salvin,

yes , I read that post. SO without saving can't we open exported result directly.To open a saved file , we need to know path also and this will change every time (depends on chosen location by user). Or do you have any idea how to capture location of the saved file from window dialog(I am using exportToSheet method which shows window dialog to chose a location for saving.)


Thanks a lot.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shikhaj jainy wrote:Or do you have any idea how to capture location of the saved file from window dialog(I am using exportToSheet method which shows window dialog to chose a location for saving.)


You can retrieve the save location/name details using the JFileChoose#fc.showSaveDialog();
OR
You can ask the user to choose the file to open using the JFileChooser#showOpenDialog();

Recommended reading: http://docs.oracle.com/javase/tutorial/uiswing/components/filechooser.html
 
shikhaj jainy
Ranch Hand
Posts: 35
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Salvin,

I got to know how we can get the path of saved file(ch.getSelectedFile().getAbsolutePath()) and we can open it , still my question is without saving , can't we open exported jtable as excel?


Thanks a lot.
 
salvin francis
Bartender
Posts: 1479
21
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shikhaj jainy wrote:... without saving , can't we open exported jtable as excel?Thanks a lot.


I don't think so. Excel is a program, if you want it to somehow display your contents, it must be given input in some form. In this case its the generated excel file.
 
shikhaj jainy
Ranch Hand
Posts: 35
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Salvin and Maneesh.

Firstly I used Desktop command to open the excel , it got opened but i was getting locked by me pop up so then I used Runtime.getRuntime().exec("cmd.exe /C start "+ xls path);
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!