-7
我想從第二行讀取excel表到第13行,也想獲得相應的列值。請向我提供代碼。 在此先感謝。閱讀excel的特定行
我想從第二行讀取excel表到第13行,也想獲得相應的列值。請向我提供代碼。 在此先感謝。閱讀excel的特定行
您應該試試reading the documentation that comes with Apache POI!
從那裏直接摘自:
// Decide which rows to process
int rowStart = Math.min(1, sheet.getFirstRowNum()); // 0 based not 1 based rows
int rowEnd = Math.max(12, sheet.getLastRowNum());
for (int rowNum = rowStart; rowNum < rowEnd; rowNum++) {
Row r = sheet.getRow(rowNum);
int lastColumn = Math.max(r.getLastCellNum(), MY_MINIMUM_COLUMN_COUNT);
for (int cn = 0; cn < lastColumn; cn++) {
Cell c = r.getCell(cn, Row.RETURN_BLANK_AS_NULL);
if (c == null) {
// The spreadsheet is empty in this cell
} else {
// Do something useful with the cell's contents
}
}
}
This bit of the docs介紹瞭如何獲得一個細胞
public class ApachePoiDoc
{
public static void main(String[] args) throws IOException, URISyntaxException
{
URL url = new URL("http://poi.apache.org/spreadsheet/quick-guide.html#ReadWriteWorkbook");
Desktop.getDesktop().browse(url.toURI());
}
}
讓我們瞭解您已經嘗試和詢問你所面臨的問題的價值。 – Kai 2013-03-20 09:51:50
[你有什麼試過](http://mattgemmell.com/2008/12/08/what-have-you-tried/)?這不是免費的編碼服務。 – 2013-03-20 09:52:15
我已經得到了行索引的行我想要什麼,並迭代在for循環。但它不能正常工作 – user2118527 2013-03-20 10:25:03