Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sheet index (1) is out of range (0..0) #41

flacohenao opened this issue Sep 11, 2017 · 3 comments


None yet
3 participants
Copy link

commented Sep 11, 2017

Hey. I'm having this error using your extension library.

when I execute the job it works just fine. but at the second time of executing, it gives me that error.

    public PoiItemReader<ActivosExcel> excelReader() throws MalformedURLException {
        PoiItemReader<ActivosExcel> reader = new PoiItemReader<>();
        reader.setResource(new UrlResource("file:\\file.xlsx") {
        return reader;

that is my Reader there... the complete error is:

Caused by: java.lang.IllegalArgumentException: Sheet index (1) is out of range (0..0)
	at org.apache.poi.xssf.usermodel.XSSFWorkbook.validateSheetIndex( ~[poi-ooxml-3.16.jar:3.16]
	at org.apache.poi.xssf.usermodel.XSSFWorkbook.getSheetAt( ~[poi-ooxml-3.16.jar:3.16]
	at org.apache.poi.xssf.usermodel.XSSFWorkbook.getSheetAt( ~[poi-ooxml-3.16.jar:3.16]
	at org.springframework.batch.item.excel.poi.PoiItemReader.getSheet( ~[spring-batch-excel-0.5.0-SNAPSHOT.jar:na]
	at org.springframework.batch.item.excel.AbstractExcelItemReader.openSheet( ~[spring-batch-excel-0.5.0-SNAPSHOT.jar:na]
	at org.springframework.batch.item.excel.AbstractExcelItemReader.doOpen( ~[spring-batch-excel-0.5.0-SNAPSHOT.jar:na]
	at ~[spring-batch-infrastructure-3.0.8.RELEASE.jar:3.0.8.RELEASE]
	... 79 common frames omitted

can you please help me? or should I do a custom Reader with POI. If that's the case, can you give me an example of how to do it?

thank you.

UPDATE: The first time that I use it, it works (my .xlsx file only have 1 sheet.) but the second time it doesnt because The Reader doesnt find a second sheet.. so it throws that error.

I did a little test and i just created another sheet in file and it worked. but still have the problem in code.

Where is the index incrementing? it should always be 0!


This comment has been minimized.

Copy link

commented Sep 12, 2017


This comment has been minimized.

Copy link

commented Sep 12, 2017

@simonbahuchet Thanks for the reply.

I solve the problem just creating the exact Reader and sheet just putting the .getIndexAt() method public and setting the sheet index I want to get.

I took a look at the library you recomended.. but its just for 2007 format, doesnt support .xlsx fortmat.

Do you think I managed that poorly?



This comment has been minimized.

Copy link

commented Dec 9, 2018

@flacohenao can you provide your code, where you have fixed above issue (Sheet index (1) is out of range (0..0)) @flacohenao

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.