projects
/
nucalgen
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d3d8e4a
)
栄養価計算の項目に含まれていない、不要な表のシート(ex.脂肪酸成分表)を出力しないようにした。
author
satomichan
<git.20200328@...>
Wed, 10 Feb 2021 20:23:59 +0000
(
05:23
+0900)
committer
satomichan
<git.20200328@...>
Wed, 10 Feb 2021 20:23:59 +0000
(
05:23
+0900)
src/main/java/jp/satomichan/nucalgen/Nucalgen.java
patch
|
blob
|
history
diff --git
a/src/main/java/jp/satomichan/nucalgen/Nucalgen.java
b/src/main/java/jp/satomichan/nucalgen/Nucalgen.java
index 690d47d439f0880de9e1bd1804a6ccd9f23407a8..f37b8b0dbebebaffa6402d8623e2246b283dc679 100644
(file)
--- a/
src/main/java/jp/satomichan/nucalgen/Nucalgen.java
+++ b/
src/main/java/jp/satomichan/nucalgen/Nucalgen.java
@@
-2,6
+2,7
@@
package jp.satomichan.nucalgen;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
@@
-96,6
+97,7
@@
public class Nucalgen {
}
//「栄養計算」行
}
//「栄養計算」行
+ List<String> usedTableList = new ArrayList<String>();
int rowIndex = 3;
for(int i = rowIndex; i < lines + 3; i++,rowIndex++) {
Row thisRow = calcSheet.createRow(rowIndex);
int rowIndex = 3;
for(int i = rowIndex; i < lines + 3; i++,rowIndex++) {
Row thisRow = calcSheet.createRow(rowIndex);
@@
-113,6
+115,8
@@
public class Nucalgen {
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++;
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++;
+
+ usedTableList.add(aColumn.getTable());
}
}
}
}
@@
-171,6
+175,21
@@
public class Nucalgen {
rowIndex = generateGroupSum(calcSheet, csPool, rowIndex, namedAreaMap);
}
rowIndex = generateGroupSum(calcSheet, csPool, rowIndex, namedAreaMap);
}
+
+ //未使用表シート削除
+ for(int si = outputWorkbook.getNumberOfSheets() - 1 ; si >= 1 ; si--) {
+ String sheetName = outputWorkbook.getSheetName(si);
+ boolean used = false;
+ for(String usedTable : usedTableList) {
+ if(usedTable.equals(sheetName)) {
+ used = true;
+ }
+ }
+ if(!used) {
+ outputWorkbook.removeSheetAt(si);
+ }
+ }
+
//ブック出力
FileOutputStream outputXlsxFile = new FileOutputStream(outputXlsxFileName);
outputWorkbook.setActiveSheet(0);
//ブック出力
FileOutputStream outputXlsxFile = new FileOutputStream(outputXlsxFileName);
outputWorkbook.setActiveSheet(0);