我在调试时遇到错误。当我放置断点并进行调试时,抛出“未找到源代码”错误。
我已经在Eclipse中单击“编辑源查找路径”并添加了我的项目。但它不起作用。请建议
Exception in thread "main" java.lang.NullPointerException
error line String value = cell.getStringCellValue();
package ExcelPractice;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFEvaluationWorkbook;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class ExcelTest {
public static void main(String[] args) throws IOException {
String value = getExcelData("sheet1",2,2);
System.out.println(" Cell Value " + value);
}
public static String getExcelData( String sheetName , int rowNum ,int cellNum) throws IOException{
FileInputStream fInput = new FileInputStream("C:\\Users\\xxxx\\Excel Data.xlsx");
XSSFWorkbook wb = new XSSFWorkbook(fInput);
XSSFSheet sheet = wb.getSheet(sheetName);
XSSFRow row = sheet.getRow(rowNum);
XSSFCell cell = row.getCell(cellNum);//breakpoint is here
String value = cell.getStringCellValue();
return value;
}
}
对于标准Java运行时中的类,最简单,最简单的答案始终是安装JDK,并使用它来编译和运行Java应用程序。Installed JREs
理想情况下,您的首选项页面应仅列出JDK。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句