IllegalArgumentexception索引超出范围groovy

时间:2014-06-13 18:41:31

标签: java groovy indexing

当我尝试调用索引时,我得到了一个非法的例子。它一直说当索引设置为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 个答案:

答案 0 :(得分:1)

您创建了一个新工作簿。

新工作簿没有工作表

您需要在工作簿中创建工作表而不是尝试获取工作表