if (output.isDirectory() == false && output.mkdirs() == false) {
throw new IOException(MessageFormat.format(
"出力先のディレクトリを生成できませんでした: {0}",
output));
}
Workbook workbook = createWorkbook();
SheetBuilder builder = new SheetBuilder(workbook, format.getVersion(), model);
for (SheetFormat sheet : format.getSheets()) {
switch (sheet.getKind()) {
case DATA:
LOG.debug("Building data sheet: {}.{}", model.getName(), sheet.getName());
builder.addData(sheet.getName());
break;
case RULE:
LOG.debug("Building rule sheet: {}.{}", model.getName(), sheet.getName());
builder.addRule(sheet.getName());
break;
default:
throw new AssertionError(MessageFormat.format(
"Unknown sheet format: {0}",
sheet));
}
}
File file = new File(output, format.getFileName(model));
LOG.debug("Emitting workbook: {}", file);
OutputStream out = new FileOutputStream(file);
try {
workbook.write(out);
} finally {
out.close();
}
LOG.info(MessageFormat.format(
"Excelワークブックを生成しました: {0}",