import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
}
//「栄養計算」行
+ List<String> usedTableList = new ArrayList<String>();
int rowIndex = 3;
for(int i = rowIndex; i < lines + 3; i++,rowIndex++) {
Row thisRow = calcSheet.createRow(rowIndex);
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());
}
}
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);