• 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

opening an xls file from the database in jsf

 
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have been given the task of opening xls files in the browser using jsf and oracle, these files are stored in the database.
How do I accomplish this?

Thanks,
Sonia
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Step 1 : Load the data to a object of type List
Step 2 : Iterate the list of the object and write the data corresponding to the excel file...
Step 3 : upload the data..

Code Snippet...

String fileName = "excelFileName";

// Create a new work book
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("mySheet1");
........
..........
........

for (SlectedObjectTO : objectList)
{
HSSFRow rows = sheet.createRow(j);

..........
........

}

// Writing data to the output stream.
FacesContext context = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext()
.getResponse();
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xls");
response.setContentType("application/vnd.ms-excel");
log.debug("Response contect :: " + response.getContentType());
ServletOutputStream out;

try
{
out = response.getOutputStream();
wb.write(out);
out.flush();
out.close();
}


Required API :: POI

 
sonia pandit
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I downloaded the poi libraries and put it in eclipse classpath and in the WEB-INF/lib directory.
But I am getting a ClassNotFoundException: org.apache.poi.usermodel.HSSFWorkBook.

Thanks,

Sonia
 
Viswanath Tg
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

May be configuration is not correct.
or More than one poi.jar is referred.
 
sonia pandit
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I got it to work. But it looks like all the examples produce an excel file. But they don't open in a swing application for editing. or in the browser. Is there such an example?

Thanks,

Sonia
 
Viswanath Tg
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am not clear with your query. can you explain it again.

Regards
Viswanath
 
sonia pandit
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am writing a jsf application in which when the user selects a file it is pulled from the database. I want to be able to open the xls file in swing or in the browser. I need an example to do that.
They need to be able to edit and save the xls file.

Thanks,

Sonia
 
Viswanath Tg
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the previous scenerio when the execl file is populated it will have 3 buttons saying open, save and close
user can click on open and edit the deatils and save.

I will let you know, once i find the solution

Regards
viswanath
 
sonia pandit
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, I need it fast though.

Sonia
 
sonia pandit
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Somebody from the apache mailing list has suggested a Servlet. Trying to figure out how
to map a servlet into a jsf application.

Thanks,

Sonia

 
Viswanath Tg
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Check the following URL.. it may satisfy your requirement.
http://www.icefaces.org/JForum/posts/list/6015.page

 
reply
    Bookmark Topic Watch Topic
  • New Topic