-2

I am getting an illegalargumentexception when I try to call the index. It keeps saying the index is out of range when it is set to 0.

sheetIndex = 0
sampleStartIndex = (37)
def MIDCellIndex = CellReference.convertColStringToIndex("I")
HSSFCell cell,containerCell, wellCell = null
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFCellStyle cellStyle = workbook.createCellStyle();
HSSFSheet worksheet = workbook.getSheetAt(sheetIndex)




Caught: java.lang.IllegalArgumentException: Sheet index (0) is out of range (0..-1)
java.lang.IllegalArgumentException: Sheet index (0) is out of range (0..-1)
    at org.apache.poi.hssf.usermodel.HSSFWorkbook.validateSheetIndex(HSSFWorkbook.java:429)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.getSheetAt(HSSFWorkbook.java:825)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.getSheetAt(HSSFWorkbook.java:73)
at org.apache.poi.ss.usermodel.Workbook$getSheetAt$0.call(Unknown Source)
at com.genologics.client.bartender.midscript.main(CSVandManifestGenerator.groovy:50)

1 Answer 1

1

You created a new workbook.

New workbooks do not have sheets

You need to create a sheet in the workbook rather than trying to get one

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.