使用 Java 源代码从 MS Excel 导入数据

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/601795/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 13:02:05  来源:igfitidea点击:

Import Data from MS Excel using Java Source Code

javaexcel

提问by AGeek

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.

我想导入放置在 MS Excel 中的数据并使用 Java 应用程序打印它。我是Java新手。所以请指导,是否可能。

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

如果是,如何?任何网站/教程都会有很大帮助..

Thanks in advance..

提前致谢..

回答by tehvan

You can use the POI libraryfor reading from excel files

您可以使用POI 库来读取 excel 文件

回答by JeeBee

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

您可以使用 jexcel API。它们总体上非常简单。http://jexcelapi.sourceforge.net/

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

我也认为 Apache POI 也在这方面工作。

回答by TofuBeer

Here is an article on using JDBC using Excel as a data source

这里有一篇使用JDBC使用Excel作为数据源的文章

回答by Jeroen van Bergen

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.

为什么不以某种非专有格式从 Excel 导出它?如果数据不是太复杂,甚至 CSV 也可以解决问题。

回答by nitin pandey

This JSP page connects the Excel sheet to the database .

这个 JSP 页面将 Excel 工作表连接到数据库。

.<%@ 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>