在Java中读取Excel文件(.xls) [英] Reading Excel file (.xls) in Java
问题描述
我想使用NetBeans从J2SE中的excel文件读取文本。我在这里发现了一篇关于使用Apache POI和JExcelApi的文章,但我宁可不依赖于外部程序包。如果可能,只使用Java内置程序包。
这个几乎工作,但它给我一个异常错误:
I want to read text from excel file in J2SE using NetBeans. I found an article here about using Apache POI and JExcelApi, but I'd prefer not depending on external packages. if possible, using only Java built-in packages.
This almost worked, but it gives me an exception error:
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
需要安装一些ODBC驱动程序(如果是,哪个驱动程序和如何安装)?
最简单的解决方法是什么?
请帮助,谢谢提前
Do I need to install some ODBC driver (if so, which driver and how to install)? What's the simplest way to solve this? please help, thanks in advance
推荐答案
总结已经说过的内容,可以从Java访问excel数据通过两步过程:
1)将excel文件设置为ODBC数据源。
2)使用JDBC-ODBC桥访问excel数据,使用标准JDBC API。
To summarize what was said already, accessing excel data from Java can be done via a two-step-process:
1) Set up the excel file as an ODBC data source.
2) Use the JDBC-ODBC bridge to access the excel data, using the standard JDBC api.
这听起来像您可能有两个问题:
1)ODBC数据源可能未设置,因此数据源未找到错误。
2)JDBC-ODBC桥驱动程序的jar可能不在您的类路径中,因此不指定驱动程序。谷歌周围为它。不难发现。
It sounds like you may have two problems:
1) The ODBC data source may not be set up, hence the "data source not found" error.
2) The jar for the JDBC-ODBC bridge driver may not be in your classpath, hence the "no driver specified". Google around for it. It's not hard to find.
这篇关于在Java中读取Excel文件(.xls)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!