-2

I am writing a web application using jsp and servlet. I uploaded an excell file using apache commomns file upload library. Now I want to extract content form the excell and store it into a database. I have thought of using apache poi library to deal with excell. My problem is how to use both these library togather.

apache commomns file upload library will represent upladed file as a FileItem instance. Now how to move ahead from here and use apache poi library, as apache poi library represents file differently.

anonymous
  • 31
  • 5
  • I would imagine you have to save the file and then open it from the filesystem with POI – developerwjk Jun 18 '14 at 16:03
  • @developerwjk Yes. I wanted to avoid that. I was expecting that there must be some kind of transformation from FileItem object to POI, as file upload and extracting its data are related task. And both the libraries are created by apache. – anonymous Jun 19 '14 at 12:12

1 Answers1

1

It looks like you can do it after all.

HSSFWorkbook has a constructor: HSSFWorkbook(java.io.InputStream s) and FileItem has java.io.InputStream getInputStream():

HSSFWorkbook workbook = HSSFWorkbook(fileitem.getInputStream());
developerwjk
  • 8,619
  • 2
  • 17
  • 33