From d41ccb85e1e04005a405e92e2028d123c1cde36e Mon Sep 17 00:00:00 2001 From: satomichan Date: Mon, 28 Dec 2020 06:59:20 +0900 Subject: [PATCH] =?utf8?q?=E3=83=BB=E7=B7=91=E9=BB=84=E8=89=B2=E9=87=8E?= =?utf8?q?=E8=8F=9C=E3=80=80=E4=BF=AE=E6=AD=A3=20=E3=83=BB=E3=80=8C?= =?utf8?q?=E8=84=82=E8=82=AA=E9=85=B8=E6=88=90=E5=88=86=E8=A1=A8=E3=80=8D?= =?utf8?q?=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../jp/satomichan/nucalgen/MextStdFoodCompTable.java | 9 +++++---- src/main/java/jp/satomichan/nucalgen/Nucalgen.java | 6 +++--- .../java/jp/satomichan/nucalgen/NutritionColumn.java | 9 +++++++++ .../jp/satomichan/nucalgen/NutritionColumnHolder.java | 2 ++ 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/main/java/jp/satomichan/nucalgen/MextStdFoodCompTable.java b/src/main/java/jp/satomichan/nucalgen/MextStdFoodCompTable.java index d851248..ec67188 100644 --- a/src/main/java/jp/satomichan/nucalgen/MextStdFoodCompTable.java +++ b/src/main/java/jp/satomichan/nucalgen/MextStdFoodCompTable.java @@ -87,16 +87,17 @@ public class MextStdFoodCompTable { } //CELL + + //食品群(1~18)書き込み compRow.createCell(62).setCellValue(group); - //緑黄色野菜か? - if(brightColoredVegetablesXmlFileName.length() > 0) { - boolean isBrightColored = false; + boolean isBrightColored = false; + if(group == 6 && brightColoredVegetablesXmlFileName.length() > 0) { String foodName = thisRow.getCell(3).getStringCellValue(); for(String aBright : this.brightColoredVegetableList) { - if(foodName.matches(aBright + ".*")) { + if(foodName.matches(".*" + aBright + ".*")) { isBrightColored = true; break; } diff --git a/src/main/java/jp/satomichan/nucalgen/Nucalgen.java b/src/main/java/jp/satomichan/nucalgen/Nucalgen.java index 9f90056..313d755 100644 --- a/src/main/java/jp/satomichan/nucalgen/Nucalgen.java +++ b/src/main/java/jp/satomichan/nucalgen/Nucalgen.java @@ -55,8 +55,8 @@ public class Nucalgen { if(cmd.hasOption("use-processed-table") == false) { //成分表 変換 - MextStdFoodCompTable moe = new MextStdFoodCompTable(cmd.getOptionValue("bright-colored-vegetables-list")); - moe.processInto(outputWorkbook); + MextStdFoodCompTable stdCompTable = new MextStdFoodCompTable(cmd.getOptionValue("bright-colored-vegetables-list")); + stdCompTable.processInto(outputWorkbook); } @@ -108,7 +108,7 @@ public class Nucalgen { String div100 = aColumn.isUseRawValue() ? "" : "/ 100 * $D" + (rowIndex + 1); - thisCell.setCellFormula("IFERROR(VLOOKUP($B" + (rowIndex + 1) + ",成分表!$B$12:$BL$2500,MATCH(\"" + aColumn.getName() + "\",成分表!$B$11:$BL$11,0),FALSE) " + div100 + ",\"\")"); + thisCell.setCellFormula("IFERROR(VLOOKUP($B" + (rowIndex + 1) + "," + aColumn.getTable() + "!$B$12:$BL$2500,MATCH(\"" + aColumn.getName() + "\"," + aColumn.getTable() + "!$B$11:$BL$11,0),FALSE) " + div100 + ",\"\")"); colIndex++; } diff --git a/src/main/java/jp/satomichan/nucalgen/NutritionColumn.java b/src/main/java/jp/satomichan/nucalgen/NutritionColumn.java index 34d7ee3..d548f25 100644 --- a/src/main/java/jp/satomichan/nucalgen/NutritionColumn.java +++ b/src/main/java/jp/satomichan/nucalgen/NutritionColumn.java @@ -2,6 +2,7 @@ package jp.satomichan.nucalgen; public class NutritionColumn { private String name; + private String table; private String dispName; private String format; private String unit; @@ -18,6 +19,14 @@ public class NutritionColumn { this.name = name; } + public String getTable() { + return table; + } + + public void setTable(String table) { + this.table = table; + } + public void setName(Object name) { this.name = (String) name; } diff --git a/src/main/java/jp/satomichan/nucalgen/NutritionColumnHolder.java b/src/main/java/jp/satomichan/nucalgen/NutritionColumnHolder.java index e20d799..78c4fd9 100644 --- a/src/main/java/jp/satomichan/nucalgen/NutritionColumnHolder.java +++ b/src/main/java/jp/satomichan/nucalgen/NutritionColumnHolder.java @@ -21,6 +21,7 @@ public class NutritionColumnHolder { this.nutritionColumnList = new ArrayList(); List names = aConfig.getList("cols.column.name"); + List tables = aConfig.getList("cols.column.table"); List dispNames = aConfig.getList("cols.column.disp_name"); List aliases = aConfig.getList("cols.column.alias"); List formats = aConfig.getList("cols.column.format"); @@ -31,6 +32,7 @@ public class NutritionColumnHolder { for (Object aName : names) { NutritionColumn nc = new NutritionColumn(); nc.setName((String) aName); + nc.setTable((String) tables.get(names.indexOf(aName))); nc.setDispName((String) dispNames.get(names.indexOf(aName))); nc.setAlias((String) aliases.get(names.indexOf(aName))); nc.setFormat((String) formats.get(names.indexOf(aName))); -- 2.43.0