javaでエクセルに計算した値を出力したいのですが、2sheet目の値が全て出力されません。
1sheet目は各sheetの合計を計算しているので2sheet目からデータを出力したいのですが、2sheet目が空になり3sheetから9sheetは出力されています。引数で渡しているデータの値は入っていました。
宜しくお願い致します。
// テンプレートからワークブックを取得 HSSFWorkbook workBook = ChohyoCommon.getWorkBook(cellIndexList.get(0).getTemplateNm(), getLogger()); // 集計期間(全シート共通) String scopeString = ChohyoCommon.toYmString(fromYm); if (!ShukeiKikanConstants.TOGETSU.getCd().equals(scope)) { scopeString = scopeString + "~" + ChohyoCommon.toYmString(ym); } //------------------------------------- // 全社計シート //------------------------------------- HSSFSheet sheet = workBook.getSheet("全社計"); sheet.getRow(0).getCell(1).setCellValue(scopeString); //------------------------------------- // 各部店ごとのシート //------------------------------------- for (int i = 0; i < ChohyoConstants.BUTEN_CD_ARRAY.length; i++) { String butenCd = ChohyoConstants.BUTEN_CD_ARRAY[i]; HanbaiJissekiChosahyoEntity entity = map.get(butenCd); if (entity != null) { sheet = workBook.getSheetAt(i); createSheet(sheet, scopeString, entity); } } workBook.setForceFormulaRecalculation(true); // 保存ファイル名 String fileName = ChohyoConstants.CHOHYO_HANBAI_JISSEKI_CHOSAHYO + "(" + ym + ")(" + ShukeiKikanConstants.getName(scope) + ")"; return ChohyoCommon.writeWorkbook(workBook, fileName, getLogger()); } private void createSheet(HSSFSheet sheet, String scopeString, HanbaiJissekiChosahyoEntity entity) { // 集計期間 sheet.getRow(0).getCell(1).setCellValue(scopeString); Map<String, HanbaiJissekiChosahyoItem> kojiSunmateMap = entity.getKojiSunmateMap(); Map<String, HanbaiJissekiChosahyoItem> kojiNotSunmateMap = entity.getKojiNotSunmateMap(); for (int i = 0; i < KOJI_SHUBETSU_ARRAY.length; i++) { // 5行目(index=4)から設定開始 HSSFRow row = sheet.getRow( SHUBETSU_ROW_POSITION + i); HanbaiJissekiChosahyoItem kojiSunmate = kojiSunmateMap.get(KOJI_SHUBETSU_ARRAY[i]); if (kojiSunmate != null) { // 件数 row.getCell(3).setCellValue(kojiSunmate.getKensu()); // 販売実績 row.getCell(4).setCellValue(kojiSunmate.getHanbai()); // 粗利益 row.getCell(5).setCellValue(kojiSunmate.getArarieki()); } HanbaiJissekiChosahyoItem kojiNotSunmate = kojiNotSunmateMap.get(KOJI_SHUBETSU_ARRAY[i]); if (kojiNotSunmate != null) { // 件数 row.getCell(12).setCellValue(kojiNotSunmate.getKensu()); // 販売実績 row.getCell(13).setCellValue(kojiNotSunmate.getHanbai()); // 粗利益 row.getCell(14).setCellValue(kojiNotSunmate.getArarieki()); } } Map<String, HanbaiJissekiChosahyoItem> dokiSunmateMap = entity.getDokiSunmateMap(); for (int i = 0; i < DOKI_SUMATE_ARRAY.length; i++) { HanbaiJissekiChosahyoItem dokiSunmate = dokiSunmateMap.get(DOKI_SUMATE_ARRAY[i]); if (dokiSunmate != null) { // 29行目(index=28)から設定開始 HSSFRow row = sheet.getRow( DOKI_ROW_POSITION + i); // 件数 row.getCell(3).setCellValue(dokiSunmate.getKensu()); // 販売実績 row.getCell(4).setCellValue(dokiSunmate.getHanbai()); // 粗利益 row.getCell(5).setCellValue(dokiSunmate.getArarieki()); } } Map<String, HanbaiJissekiChosahyoItem> dokiNotSunmateMap = entity.getDokiNotSunmateMap(); for (int i = 0; i < DOKI_NOT_SUMATE_ARRAY.length; i++) { HanbaiJissekiChosahyoItem dokiNotSunmate = dokiNotSunmateMap.get(DOKI_NOT_SUMATE_ARRAY[i]); if (dokiNotSunmate != null) { // 29行目(index=28)から設定開始 HSSFRow row = sheet.getRow( DOKI_ROW_POSITION + i ); // 件数 row.getCell(12).setCellValue(dokiNotSunmate.getKensu()); // 販売実績 row.getCell(13).setCellValue(dokiNotSunmate.getHanbai()); // 粗利益 row.getCell(14).setCellValue(dokiNotSunmate.getArarieki()); } } }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/03/16 01:39