https://issues.apache.org/bugzilla/show_bug.cgi?id=56325

            Bug ID: 56325
           Summary: IndexOutOfBoundsException in removeSheetAt(0)
           Product: POI
           Version: 3.10
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
          Assignee: dev@poi.apache.org
          Reporter: frolovs...@gmail.com

Created attachment 31448
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=31448&action=edit
An example of XLS file to help you reproduce a bug

Steps to reproduce:
1. Create an empty XLS file with 3 sheets (they're there by default)
2. On the 3rd sheet create 6 named ranges. The scope of those names must be
that sheet, not the workbook (it is important!), so do it with Name Manager.
3. Run the code:

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

import java.io.FileInputStream;
import java.io.IOException;

public class Test {

  public static void main(String[] args) throws IOException {
    POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("empty.xls"));
    HSSFWorkbook wb = new HSSFWorkbook(fs);
    wb.removeSheetAt(0);
  }
}

Expected result is:
- the first sheet is being removed from the sheet.

The actual result is:
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 3, Size:
3
    at java.util.ArrayList.RangeCheck(ArrayList.java:547)
    at java.util.ArrayList.get(ArrayList.java:322)
    at
org.apache.poi.hssf.record.ExternSheetRecord.getRef(ExternSheetRecord.java:164)
    at
org.apache.poi.hssf.record.ExternSheetRecord.adjustIndex(ExternSheetRecord.java:168)
    at
org.apache.poi.hssf.model.LinkTable.updateIndexToInternalSheet(LinkTable.java:419)
    at
org.apache.poi.hssf.model.InternalWorkbook.removeSheet(InternalWorkbook.java:721)
    at
org.apache.poi.hssf.usermodel.HSSFWorkbook.removeSheetAt(HSSFWorkbook.java:899)
    at Test.main(Test.java:12)

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org

Reply via email to