Deletion of sheet fails

Issue #32 resolved
Jaroslav Svoboda
created an issue

Version 2.2.8 From my previous issue #27, after fix, there is problem with When first 16 out of 17 sheets are deleted immediatelly after the PoiTransformer is created and BEFORE, then IllegalArgumentException is thown.

java.lang.IllegalArgumentException: Sheet index (-1) is out of range (0..0)
    at HSSFWorkbook.validateSheetIndex(
    at HSSFWorkbook.getSheetName(
    at HSSFSheet.getSheetName(
    at PoiTransformer.readCommentsFromSheet(
    at PoiTransformer.getCommentedCells(

Map sheetMap in PoiTransformer.getCommentedCells(line 211) has 17 sheets, but i expect 1 because i deleted other sheets.

Comments (9)

  1. LeonidV repo owner

    I need a concrete example to reproduce it.

    I have tried to modify XlsCommentBuilderDemo to remove some additional sheets before and it worked fine without any issues.

  2. LeonidV repo owner

    how to run it?

    I have tried executing "ant" command but the build fails for me.

    I was not able to configure it in IDE as well (I use Intellij).

    It probably requires some manual path settings in IDE but I have not worked with Apache Ant for 10 years so do not remember all the tricks.

  3. Jaroslav Svoboda reporter

    i simply created ordinary java project in netbeans "file -> new project -> java application", right clicked on project's "libraries" and manually added all from "jxls-2.2.8\dist" and from "jxls-dependencies". maybe its similar in intellij.

    it should be possible for you to create new project as usual and then simply copy files from "src" or to copy files from "src" to your demo projects :)

  4. LeonidV repo owner

    The root cause of the error was that the sheet was deleted from the Workbook but not from the internal sheet map.

    And the reason for that was that you passed the name of a sheet as 'Fx Risk' but the sheet was actually stored as 'FX Risk' and the keys are case sensitive. So it just could not delete and sheet from the map but was able to delete from the Workbook.

    Now I have added a warning if the sheet cannot be deleted from the sheet map and also skip the deletion of the sheet from the Workbook.

  5. Log in to comment