• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to open exported excel from jtable

 
Ranch Hand
Posts: 35
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your solution is here : https://coderanch.com/t/446476/java/java/open-excel-file-java-program

 
shikhaj jainy
Ranch Hand
Posts: 35
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
 
reply
    Bookmark Topic Watch Topic
  • New Topic