I read an excel with:
FileInputStream fis = new FileInputStream(new File("C:\\miPlantilla.xlsx"));
XSSFWorkbook workbook = new XSSFWorkbook (fis);
XSSFSheet sheet;
if(condicion) {
sheet = workbook.getSheetAt(0);
} else {
sheet = workbook.getSheetAt(1);//<-Uso otra hoja
}
XSSFRow row;
XSSFCell cell;
//Modifico datos.
Now what I try to hide one of the two sheets:
if(condicion) {
workbook.setSheetHidden(0, true);
} else {
workbook.setSheetHidden(1, true);
}
But it throws me the exception:
Caused by: java.lang.IllegalArgumentException: Sheet index (2) is out of range (0..1)
Does anyone know what I'm doing wrong?
In the end I needed to activate the other sheet so that it hides the sheet.