尝试运行下面的代码时出现以下错误(涉及读取在 Java 中工作的 Excel 电子表格数据),但出现以下错误...
错误 StatusLogger Log4j2 找不到日志记录实现。请将 log4j-core 添加到类路径中。使用 SimpleLogger 登录到控制台...
...我在想我应该只包含一些 Log4j2 包,但被告知这实际上是 Java 和 Workbook 类本身的问题。这些是我在 build.gradle 文件中设置的依赖项...
implementation 'org.apache.commons:commons-collections4:4.4' // https://commons.apache.org/proper/commons-collections/download_collections.cgi
implementation 'org.apache.poi:poi:5.2.3' // https://mvnrepository.com/artifact/org.apache.poi/poi
implementation 'org.apache.poi:poi-ooxml:5.2.3' // https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml
implementation 'org.apache.poi:poi-ooxml-schemas:4.1.2' // https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml-schemas
implementation 'org.apache.xmlbeans:xmlbeans:5.1.1' // https://mvnrepository.com/artifact/org.apache.xmlbeans/xmlbeans
虽然有问题的代码如下...
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Iterator;
@SuppressWarnings("ALL")
public class appium_stuff
{
@Test
public void test() throws IOException
{
FileInputStream fis = new FileInputStream("D:\\[some Windows dir]\\[name of file].xlsx");
Workbook wb = WorkbookFactory.create(fis); // <<< error references this line
Sheet sheet = wb.getSheet("Sheet1");
}
}