既存のエクセルシートに直に入れていたデータをデータベースから取るようにしたところ、
直にデータを入れていたセルを参照しているセル計算式が消えて#VALUE!になってしまいました。
setForceFormulaRecalculationで再計算しているはずなのですがうまくいきません。
宜しくお願い致します。
以下が追加した分のソースになります。
HSSFSheet goalSheet = workbook.getSheet("目標"); HSSFRow goalRow = goalSheet.getRow(2); HSSFCell goalCell = goalRow.getCell(1); goalCell = goalRow.getCell(16); goalCell.setCellValue(criteria.getMaterial_date().substring(0, 4) + "/4/1"); // 画面のリストボックス「部門名」用のリストを取得 for (int i = 0; i < bumonInfoAccess.getButenInfoList(BumonInfoAccess.BUMON_SELECT_FLG_OFF).size(); i++) { //部門コードを取得 int ade = bumonInfoAccess.getButenInfoList(BumonInfoAccess.BUMON_SELECT_FLG_OFF).get(i).getBumon_cd(); //部門名を取得 String adNm = bumonInfoAccess.getButenInfoList(BumonInfoAccess.BUMON_SELECT_FLG_OFF).get(i).getBumon_nm(); AnnualsalestargetAccess ASTAdao = new AnnualsalestargetAccess(getLogger(), getDbAccessInfo()); //年間目標をDBから取得 ArrayList<AnnualsalestargetEntity> ASTAlist = ASTAdao.getAnnualsalestarget(criteria.getMaterial_date().substring(0, 4), ade); AnnualsalestargetEntity ASTAtotal = new AnnualsalestargetEntity(); for (AnnualsalestargetEntity entity : ASTAlist) { ASTAtotal.setAprsalesValue(ASTAtotal.getAprsalesValue() + entity.getAprsalesValue()); ASTAtotal.setMaysalesValue(ASTAtotal.getMaysalesValue() + entity.getMaysalesValue()); ASTAtotal.setJunsalesValue(ASTAtotal.getJunsalesValue() + entity.getJunsalesValue()); ASTAtotal.setJulsalesValue(ASTAtotal.getJulsalesValue() + entity.getJulsalesValue()); ASTAtotal.setAugsalesValue(ASTAtotal.getAugsalesValue() + entity.getAugsalesValue()); ASTAtotal.setSepsalesValue(ASTAtotal.getSepsalesValue() + entity.getSepsalesValue()); ASTAtotal.setOctsalesValue(ASTAtotal.getOctsalesValue() + entity.getOctsalesValue()); ASTAtotal.setNovsalesValue(ASTAtotal.getNovsalesValue() + entity.getNovsalesValue()); ASTAtotal.setDecsalesValue(ASTAtotal.getDecsalesValue() + entity.getDecsalesValue()); ASTAtotal.setJansalesValue(ASTAtotal.getJansalesValue() + entity.getJansalesValue()); ASTAtotal.setFebsalesValue(ASTAtotal.getFebsalesValue() + entity.getFebsalesValue()); ASTAtotal.setMarsalesValue(ASTAtotal.getMarsalesValue() + entity.getMarsalesValue()); } //セットする goalRow = goalSheet.getRow(i+2); goalCell = goalRow.createCell(17); goalCell.setCellValue(ade); goalCell = goalRow.createCell(18); goalCell.setCellValue(adNm); goalCell = goalRow.createCell(19); goalCell.setCellValue(ASTAtotal.getAprsalesValue()); goalCell = goalRow.createCell(20); goalCell.setCellValue(ASTAtotal.getMaysalesValue()); goalCell = goalRow.createCell(21); goalCell.setCellValue(ASTAtotal.getJunsalesValue()); goalCell = goalRow.createCell(22); goalCell.setCellValue(ASTAtotal.getJulsalesValue()); goalCell = goalRow.createCell(23); goalCell.setCellValue(ASTAtotal.getAugsalesValue()); goalCell = goalRow.createCell(24); goalCell.setCellValue(ASTAtotal.getSepsalesValue()); goalCell = goalRow.createCell(25); goalCell.setCellValue(ASTAtotal.getOctsalesValue()); goalCell = goalRow.createCell(26); goalCell.setCellValue(ASTAtotal.getNovsalesValue()); goalCell = goalRow.createCell(27); goalCell.setCellValue(ASTAtotal.getDecsalesValue()); goalCell = goalRow.createCell(28); goalCell.setCellValue(ASTAtotal.getJansalesValue()); goalCell = goalRow.createCell(29); goalCell.setCellValue(ASTAtotal.getFebsalesValue()); goalCell = goalRow.createCell(30); goalCell.setCellValue(ASTAtotal.getMarsalesValue()); } // ワークシートの埋め込み関数を再計算 goalSheet.setForceFormulaRecalculation(true); HSSFSheet tsukiGoalSheet = workbook.getSheet("通期目標"); tsukiGoalSheet.setForceFormulaRecalculation(true);
回答1件
あなたの回答
tips
プレビュー