开发者

How to read a Excel file that is selected and submitted in JSP form?

The end user will select an excel file on executing the below jsp program.

   <form action="?? " method="post" enctype="multipart/form-data" name=开发者_运维问答"form1" id="form1"> 

    Upload File:
   <input name="file" type="file" id="file"><br><br>
   <input type="submit" name="Submit" value="Submit"/><br><br>
   <input type="reset" name="Reset" value="Reset"/>   
   </form>

The excel sheet will be in a specified format which need to be read and compared with the contents of Database.

My query here is how should I proceed with this once the user browses the excel file and submits the jsp form.

How the excel sheet can be invoked to a java program and please explain me the steps of doing the same. Am a beginner in java and I would be so thankful if your answer is self explanatory.

Thanks in advance.


You can manipulate Excel documents with the Apache POI API.


Your action should redirect you to a servlet which will handle the file. You'll need to handle multipart files, you can use Apache file upload to do this.


Resources :

  • Apache POI - Case studies
  • Apache POI - FAQ
  • Reading and Writing Excel Files with POI
  • How do I upload a file to my servlet or JSP?
  • How to use apache fileupload

On the same topic :

  • Learning Apache POI for Java
  • Reading date values from excel cell using POI HSSF API
  • Managing file uploads in JSP/Servlets


Apache already invented a library to read excel sheet. Its name is Apache Poi. It's free and it's well documented. And of course a sample code is available

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜