java - 类型 Workbook 的方法 getWorkbook(FileInputStream) 未定义
问题描述
我正在尝试使用 JAVA 编写 Selenium 代码,以使用 Apache POI 从 excel 中获取输入。下面是代码,我收到错误消息'The method getWorkbook(FileInputStream) is undefined for the type Workbook' for the statement Workbook wb = Workbook.getWorkbook(fs); 请帮我解决这个问题。
public class Main {
public static void main(String[] args) {
File file = new File("C:/Users/425413/NewWorkspace/Telecom/datafile.properties");
FileInputStream fileInput = null;
try {
fileInput = new FileInputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Properties prop = new Properties();
//load properties file
try {
prop.load(fileInput);
} catch (IOException e) {
e.printStackTrace();
}
System.setProperty("webdriver.chrome.driver","C:\\Users\\425413\\Documents\\Raji\\chromedriver_win32-for79\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get(prop.getProperty("URL"));
String FilePath = "d://filepath.xls";
FileInputStream fs = new FileInputStream(FilePath);
Workbook wb = Workbook.getWorkbook(fs);
}
}
解决方案
尝试
WorkbookFactory.create
推荐阅读
- kubernetes - 无法从 K8s 中具有命名空间管理员访问权限的 kubectl 客户端创建部署/配置映射
- apache-spark - Structured Streaming + Kafka:生产者关闭后无法发送
- c++ - 将字段声明为 const 调用“函数 operator=(const memAddress &) 不能被引用——它是一个已删除的函数”
- python - 为什么当我将状态设置为 false 时程序没有跳出 while 循环?
- git - git update production server 导致没有这样的文件或目录错误
- javascript - 脚本类型 text/json 的最大大小是多少
- node.js - 谷歌使用节点的警报 api
- vb.net - RichTextBox Paste 遇到问题
- python - 为什么python程序不显示结果
- intellij-idea - Datanucleus Enhancer:IntelliJ:插件问题