【发布时间】:2017-05-09 05:47:02
【问题描述】:
我的脚本是检查两个 excel 文件(xlsx 以不同的时间间隔从 Web 应用程序导出,例如更新前和更新后),其中包含相同数量的选项卡和多列。一切都是一样的,但我必须比较值。我已经完成了 4 组,但在第 5 组中挣扎。无法读取文件。检查 1) 尺寸 2) 减少纸张 3) 删除了一些数据但没有用。有时它在调试 1:10 时正在读取,但在运行时它显示 Null 指针异常。
try {
// Open the Excel file
String FileNameforScriptsFilePath = "D:\\Functional Automation
Data\\Pest WTO with change before.xlsx";
FileInputStream FileNameforScriptsFile = new
FileInputStream(FileNameforScriptsFilePath);
XSSFWorkbook DataCleanBefore = new
XSSFWorkbook(FileNameforScriptsFile);
// File DataCleaningBeforeFile=new File("D:\\Functional Automation
Data\\Pest RTO with change before.xlsx");//all are similar names
// OPCPackage PestWTOwithchangebeforepkg =
OPCPackage.open(DataCleaningBeforeFile.getAbsolutePath());
// XSSFWorkbook DataCleanBefore = new
XSSFWorkbook(PestWTOwithchangebeforepkg);
XSSFSheet BasicAddressDetailsBeforeSheet =
DataCleanBefore.getSheet("Basic Address Details");
我也尝试过使用 SXSSFSheet,以及上面在 // OPC 中给出的。请帮助,自 4 天以来一直在苦苦挣扎。
【问题讨论】:
-
您好,当您的任何变量被声明但未初始化时,我们会得到空指针。交叉检查所有声明的变量是否在使用前初始化。