java i无法读取总行数有些行杂乱无章
我需要调试下面的代码,以跟踪while循环开始时的一些意外结果。我把断点放在while循环的行中,但调试器没有到达它。我希望调试器在该行之前运行所有代码,然后在要调试的行处一步一步地停止。我该怎么做 公共类MainActivity扩展了AppCompatActivity{
Button readExcelButton;
static String TAG = "ExelLog";
ArrayList<PhoneData> phoneData = new ArrayList<PhoneData>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void readFile(View view) {
if (!isExternalStorageAvailable() || isExternalStorageReadOnly()) {
Log.e(TAG, "Storage not available or read only");
return;
}
try {
//创建输入流
File file = new File(this.getExternalFilesDir(null), "3.xls");
// FileInputStream myInput = new FileInputStream(file);
InputStream inStream;
Workbook wb = null;
inStream = new FileInputStream(file);
//使用文件系统创建工作簿
wb = new HSSFWorkbook(inStream);
//从工作簿中获取第一张工作表 活页1=wb。getSheetAt(0)
int totalNumberOfRows = sheet1.getLastRowNum();
Log.d(TAG, "RowsNo: " + totalNumberOfRows);
int i = 6;
while (i <= totalNumberOfRows) {
if (sheet1.getRow(i).getCell(16).getCellTypeEnum() == CellType.NUMERIC) {
double duration = sheet1.getRow(i).getCell(16).getNumericCellValue();
if (duration > .91 && duration < 1) {
//sheet1.getRow(i).getCell(8).setCellType(CellType.NUMERIC);
double status = sheet1.getRow(i).getCell(8).getNumericCellValue();
if (status == 60 || status == 72 || status == 73 || status == 101) {
System.out.println("if succeed");
Double telephone = sheet1.getRow(i).getCell(2).getNumericCellValue();
int tel = telephone.intValue();
System.out.println("telephone is" + tel);
}
//Toast.makeText(this, "Telephone Number: " + Double.toString(telephone), Toast.LENGTH_SHORT).show();
// String exchange = sheet1.getRow(i).getCell(1).getStringCellValue();
// String complainTime =sheet1.getRow(i).getCell(5).getStringCellValue();
// phoneData.add(new PhoneData(Double.toString(telephone), exchange,Double.toString(status),complainTime));
// System.out.println("exchange is"+exchange + duration+status+complainTime );
}
System.out.println("Test Data From Excel" + duration);
System.out.println("Row Number" + i);
} else {
System.out.println("Not Numeric");
}
i++;
}
} catch (Exception e) {
e.printStackTrace();
}
return;
}
private static boolean isExternalStorageReadOnly() {
String extStorageState = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(extStorageState)) {
return true;
}
return false;
}
private static boolean isExternalStorageAvailable() {
String extStorageState = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(extStorageState)) {
return true;
}
return false;
}
}
共 (0) 个答案