From 0576fa8bb36617412091cffc91ca1257816f059c Mon Sep 17 00:00:00 2001 From: satomichan Date: Thu, 27 May 2021 12:31:15 +0900 Subject: [PATCH] =?utf8?q?=E2=98=85=E3=80=8CPFC=E3=83=90=E3=83=A9=E3=83=B3?= =?utf8?q?=E3=82=B9=E3=80=8D=E3=81=AE=E7=AE=97=E5=87=BA=E6=96=B9=E6=B3=95?= =?utf8?q?=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit     1. たんぱく質エネルギー比率(%)         =たんぱく質量(g)×4(kcal)÷エネルギー量(kcal)× 100     2. 脂質エネルギー比率(%)         =脂質量(g)×9(kcal)÷エネルギー量(kcal)× 100     3. 炭水化物エネルギー比率(%)         =100(%)- (たんぱく質エネルギー比率(%)+脂質エネルギー比率(%)) https://eiyo21.com/blog/fd_vol17/ の 「成分表2015年版(七訂)の計算方法のエネルギーを使った場合のエネルギー産生栄養素バランス」の計算方法による。 ★「PFCバランス」の各値を整数に丸める(小数点以下で四捨五入)ように変更した。 --- src/main/java/jp/satomichan/nucalgen/Nucalgen.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/jp/satomichan/nucalgen/Nucalgen.java b/src/main/java/jp/satomichan/nucalgen/Nucalgen.java index 9eb18fc..3c9dbcc 100644 --- a/src/main/java/jp/satomichan/nucalgen/Nucalgen.java +++ b/src/main/java/jp/satomichan/nucalgen/Nucalgen.java @@ -207,20 +207,22 @@ public class Nucalgen { pfbBalanceRow1.createCell(4).setCellValue("F"); pfbBalanceRow1.createCell(5).setCellValue("C"); - final String sumPfc = "(" + _namedAreaMap.get("SUM_P") + "*4+" + _namedAreaMap.get("SUM_F") + "*9+" + _namedAreaMap.get("SUM_C") + "*4)"; + final String sumKiloCalorieCell = _namedAreaMap.get("SUM_KCAL"); rowIndex++; Row pfbBalanceRow2 = calcSheet.createRow(rowIndex); Cell pCell = pfbBalanceRow2.createCell(3); pCell.setCellStyle(csPool.getCellStyle("0")); - pCell.setCellFormula(_namedAreaMap.get("SUM_P") + "*4*100/" + sumPfc); + pCell.setCellFormula("ROUND(" + _namedAreaMap.get("SUM_P") + "*4*100/" + sumKiloCalorieCell + ",0)"); Cell fCell = pfbBalanceRow2.createCell(4); fCell.setCellStyle(csPool.getCellStyle("0")); - fCell.setCellFormula(_namedAreaMap.get("SUM_F") + "*9*100/" + sumPfc); + fCell.setCellFormula("ROUND(" + _namedAreaMap.get("SUM_F") + "*9*100/" + sumKiloCalorieCell + ",0)"); + Cell cCell = pfbBalanceRow2.createCell(5); cCell.setCellStyle(csPool.getCellStyle("0")); - cCell.setCellFormula(_namedAreaMap.get("SUM_C") + "*4*100/" + sumPfc); + cCell.setCellFormula("100 - (" + new CellReference(cCell.getRowIndex(), 3).formatAsString() + " + " + + new CellReference(cCell.getRowIndex(), 4).formatAsString() + ")"); return rowIndex; } -- 2.43.0