简体   繁体   中英

Import Data from MS Excel using Java Source Code

I want to Import data placed in MS Excel and print it using Java Application Program. I am newbie in Java. So Please guide, is it possible.

If yes, how? Any website/tutorial will be of great help..

Thanks in advance..

您可以使用POI库读取Excel文件

You can use the jexcel APIs. They're quite simple overall. http://jexcelapi.sourceforge.net/

I also think that Apache POI is working on this area as well.

.<%@ page import="java.sql.*" %><br/>
.<% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); %>

<BODY>               

.<%
  Connection con=DriverManager.getConnection("jdbc:odbc:DsnName");<br/>
  Statement stm=con.createStatement();<br/>
  ResultSet rs=stm.executeQuery("select * from [Sheet1$]");       
%>

.<% if(!rs.next()) {
    out.println("Sorry, could not find data");
 }
 else { %>
  .<%=rs.getString(1)%>
.<%}%>

</BODY>

Why not export it from Excel in some format that is not proprietary? If the data is not too complex, even CSV might do the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM