I think this is the problem:
while (cell != null && !(cell.toString().equals("")))
{
// We know that cell isn't null before this line...
cell = headingsRow.getCell(i);
// ... but now we've got a new value for cell, which could be null
columnHeading = cell.toString();
columnHeadings.add(columnHeading);
i++;
}
I suspect you want to change it to:
while (cell != null && !(cell.toString().equals("")))
{
// We know cell isn't null for this...
columnHeading = cell.toString();
columnHeadings.add(columnHeading);
i++;
// It's fine to set cell to null here... we'll be
// checking again in a second...
cell = headingsRow.getCell(i);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…