gpt4 book ai didi

java - HSSFSheet 类型的 getCell(int) 方法未定义

转载 作者:行者123 更新时间:2023-12-02 05:08:27 25 4
gpt4 key购买 nike

我正在尝试构建一个二维数组,该数组保存数据表中的值,然后获取这些值并将它们显示在网站申请表中。我不断得到

The method getCell(int) is undefined for the type HSSFSheet

错误,我不知道为什么。

public static void main(String[] args) throws Exception {
File file = new File(
"C:\\Users\\865\\Desktop\\ETAF Selenium\\etaf-selenium-installer\\bin\\Drivers\\64-bit\\IEDriverServer.exe");

System.setProperty("webdriver.ie.driver", file.getAbsolutePath());

File picassoinput = new File("C:\\Users\\865\\Desktop\\ETAF Selenium\\Data Sheets\\PicassoInputData.xls");
FileInputStream picassofis = new FileInputStream(picassoinput);
HSSFWorkbook picassowb = new HSSFWorkbook(picassofis);
HSSFSheet picassows = picassowb.getSheet("Data");

int rowNum = picassows.getLastRowNum() + 1;
int colNum = picassows.getRow(0).getLastCellNum();
String[][] datainput = new String[rowNum][colNum];

for (int i = 0; i < rowNum; i++) {
HSSFRow row = picassows.getRow(i);

for (int j = 0; j < colNum; j++) {
// the below row of code "HSSFCell cell picassows.getCell(j); is where the error is
// at

HSSFCell cell = picassows.getCell(j);

String value = cellToString(cell);
datainput[i][j] = value;
}

}

Test2 a = new Test2();

a.setUp();

a.testCase();
}

最佳答案

以下是代码中唯一相关的部分:

HSSFSheet picassows = picassowb.getSheet("Data");
...
HSSFCell cell = picassows.getCell(j);

正如错误所述:HSSFSheet 没有 HSSFCell!

您可能想要:

HSSFCell cell = row.getCell(j);

关于java - HSSFSheet 类型的 getCell(int) 方法未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27555374/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com