方法getCell(int)对于HSSFSheettypes是未定义的

我试图构build一个2维数组,它保存数据表中的值,然后将这些值显示在网站应用程序表单中。 我不断收到

方法getCell(int)对于HSSFSheettypes是未定义的

错误,我不知道为什么。

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);