2010-09-08 101 views
2

我的Excel表單包含許多列和許多行。使用Apache POI讀取Excel表單的列

我想程序只讀取第一列的內容並顯示在輸出中。

使用

for (Row row : sheet) { 
    for (Cell cell : row) { 
     // Printing Stuff 
     } 
    } 

上面的代碼打印excel工作表的所有單元中的內容。 但我希望僅打印第一列的內容。

如何更改此代碼?我是java的初學者。請幫助

回答

4

你可以試試這個:

for (Row row : sheet) { 
    Cell firstCell = row.getCell(0); 
    // Printing Stuff 
} 

資源:

+0

那完美的科林。謝謝 :) – LGAP 2010-09-08 20:52:36