1

I am trying to upload xlsx file and read it's content to insert into database.

I completed download xlsx but facing issue in upload and reading the content

Here is the jsp:

<div align="center" style="margin-bottom: 10px;" >
                        <input style="width:200px" class="admin_search_btn" type=file name="uploadxls" value=""  />
                     </div>
                <div align="center" style="margin-bottom: 10px;" >  
                    <button type="submit" class="admin_search_btn">Submit</button>&nbsp;
                    <button type="submit" class="admin_search_btn">Cancel</button>
                </div>

How should I map this to controller to upload the file on server and read it's content?

2 Answers2

0

A file upload differs from a normal post (POST, GET). If you follow this tutorial Link or here you will see what you missed:

• a form tag, that allows a "multipart" post

<form method="POST" enctype="multipart/form-data" action="/upload">

• a servlet that handles your upload

Please give us more details what you need.

Markus
  • 763
  • 7
  • 24
0

Upload File to Server:

Uploading a file on server has been already answered with an excellent explanation in this question's answer .

Reading xlsx file using java:

Use Apache-poi to read its content from the file.Apache POI is a Java library to work with different Microsoft Office file formats such as Excel, Power point, Visio, MS Word etc.

I found this article useful as I have also followed this article to get started with Apache-poi.

Community
  • 1
  • 1
Abhijeet Panwar
  • 1,837
  • 3
  • 26
  • 48