How to read an excel file contents on client side?

前端 未结 5 1803
小蘑菇
小蘑菇 2020-11-30 05:13

From the JSP page, I need to browse excel file and after selecting file on system, I need to read that excel file contents and fill my form.

Currently I have tried

5条回答
  •  鱼传尺愫
    2020-11-30 05:50

    It is generally not possible to read/write any file via JavaScript in a browser. So without any additional plug-ins you will not be able to read/write Excel files from the browser. The ActiveX objects of Excel let you do this, but only IE supports ActiveX objects.

    There may be other plugins for other browsers, but i am aware of none.

    In the first place, why do you want to do that? Can you give a use case? Perhaps there are better options available than what you are trying.

    UPDATE

    You will have to pass the excel file to the server and do the reading of the excel in the server side (in a servlet for instance).

    You will have to use a in the JSP within a multipart form

    On the server side, you may want to use Apache Commons File Upload.

    Once you have the file (or a stream on it) you can parse the file using, say, Apache POI HSSF/XSSF and then update the data to a database or pass it back to a JSP

提交回复
热议问题