我想讀取一個電子表格的表單使用foor循環。我想知道這是讀特別是用表歡迎使用屬性的正確方法[代碼高亮]:閱讀多個Excel表格
Cell[][] newcell=new Cell[200][200];
int newsheet = workbook1.getNumberOfSheets();
for (int q=1;q < newsheet;q++)
{
for(int p=0;p < sheet(q).getColumns();p++)
{
for(int p1=0;p1<sheet(q).getRows();p1++)
/*^^^^^^^^^*/
{
newcell[p][p1] = sheet(q).getCell(p, p1);
/*^^^^^^^^^*/
if(newcell[p][p1].equals(saved[j]))
{
System.out.print(newcell[p][0]);
}
}
}
}
我可以使用表()爲片(Q)的,因爲它的投擲NullPointerExeption的財產?
*,其中*你得到一個NullPointerException? – 2011-05-19 09:30:58
@Andreas_D for(int p1 = 0; p1
user756742
2011-05-19 09:36:17
@ user756742 - 你的自定義'sheet(int i)'方法裏面肯定有錯誤。 'sheet(q)'有時會返回一個對象,有時會返回'null'作爲'q'的相同值 - 這不應該發生。 – 2011-05-19 09:42:50