2017-09-06 114 views
0
// Declaring the path of the Excel file with the name of the Excel file 
      String sPath = "E:\\Practice_space\\MyKDTTest\\src\\dataengine\\DataEngine.xlsx"; 

      // Here we are passing the Excel path and SheetName as arguments to connect with Excel file 
      ExcelUtils.setExcelFile(sPath, "TestSteps"); 

上面的代碼是我在java的主類中提到的。我打電話這是已經在其他類如波紋管方法setExcelFile(String,String)未定義爲類型ExcelUtils

public static void setExcelFile(String Path,String SheetName) throws Exception { 
     FileInputStream ExcelFile = new FileInputStream(Path); 
     ExcelWBook = new XSSFWorkbook(ExcelFile); 
     ExcelWSheet = ExcelWBook.getSheet(SheetName); 
     } 

但我得到一個錯誤,請幫我定義的方法setExcelFile,在此先感謝

+0

你確定'setExcelFile'方法在'ExcelUtils'類中嗎? – ByeBye

+0

是這樣的錯誤嗎?:https://stackoverflow.com/questions/26034994/selenium-with-java-and-testng-test-login-with-excel-datasheet –

+0

你可以清除並重建你的項目來獲取擺脫問題。 – Murthi

回答

1

「簡單」:類ExcelUtils的編譯器是看到編譯上面的代碼時不是包含那個方法的定義。

換句話說:在您的設置中的東西是錯誤的。例如,當你的更改類的java源代碼時,會發生這樣的事情 - 但你忘記編譯它。或者你忘記重建你的JAR檔案。

長話短說:在您的設置中存在某種不一致。由於我們對該設置沒有深入瞭解,所以在這裏可以這麼說!

相關問題