示例#1
0
 /**
  * セルの値を取得する
  *
  * @param row 行データ
  * @param nColumn 列番号
  * @return セルの値
  */
 public static Object getData(XSSFRow row, int nColumn) {
   if (row != null) {
     XSSFCell cell = row.getCell(nColumn);
     if (cell != null) {
       if (XSSFCell.CELL_TYPE_NUMERIC == cell.getCellType()) {
         return cell.getNumericCellValue();
       } else if (XSSFCell.CELL_TYPE_STRING == cell.getCellType()) {
         return cell.getStringCellValue();
       }
     }
   }
   return null;
 }
示例#2
0
 /**
  * 列方向のセルの値を合算する
  *
  * @param sheet 編集対象シート
  * @param nColumn 行番号
  * @param nStartRow 開始列番号
  * @param nEndRow 終了列番号
  * @return 合算値
  */
 public static int sumColumn(XSSFSheet sheet, int nColumn, int nStartRow, int nEndRow) {
   int sum = 0;
   for (int nIndex = nStartRow; nIndex <= nEndRow; nIndex++) {
     XSSFRow row = sheet.getRow(nIndex);
     assert row != null;
     XSSFCell cell = row.getCell(nColumn);
     assert cell != null;
     if (cell.getCellType() == XSSFCell.CELL_TYPE_NUMERIC) {
       sum += cell.getNumericCellValue();
     }
   }
   return sum;
 }