if (matcher.group(1) != null) {
int sheetNumber = Integer.parseInt(matcher.group(1));
LOG.debug("Opening sheet by index : {}", sheetNumber);
try {
Sheet sheet = book.getSheetAt(sheetNumber);
assert sheet != null;
return sheet;
} catch (RuntimeException e) {
throw new IOException(MessageFormat.format(
"Excelシートの展開に失敗しました: {0} (シート{1}番がありません)",
source,
sheetNumber), e);
}
} else {
String sheetName = matcher.group(2);
LOG.debug("Opening sheet by name : {}", sheetName);
assert sheetName != null;
Sheet sheet = book.getSheet(sheetName);
if (sheet == null) {
throw new IOException(MessageFormat.format(
"Excelシートの展開に失敗しました: {0} (シート\"{1}\"がありません)",
source,
sheetName));