2014-02-11 27 views
0

我使用Apache POI在Android應用程序,但我有一個問題的Android的Apache POI異常

我想指出一個空單元格,但我有一個空poiter例外:

Cell cellTest = rowTest.getCell(0,Row.CREATE_NULL_AS_BLANK); 

我不明白這個例外

+0

你如何定義你的rowTest? – PopoFibo

+0

是的,問題是單元格 – user3244162

+0

Row rowTest = feuille.getRow(test); // test is an Int var – user3244162

回答

0

我認爲你的行不存在(變量爲空)。我想因爲你是在你目前的工作表結束後。如果該方法返回true,則需要創建行

/** 
* This method return a boolean which represent if the line is after the end of file or not 
* @param pSheet sheet concerned 
* @param pRow row to verify 
* @return true if the line number is the last or after the last of the file 
*/ 
public static boolean isEndOfSheet(Sheet pSheet, int pRow) 
{ 
    return (pSheet.getLastRowNum() < pRow); 
} 

你可以做測試用下面的方法。

feuille.createRow(rowNumber) // this return the Row created 

對於新文件,您需要創建要放入文件的每一行和單元格。