Issue #32 resolved

Deletion of sheet fails

Jaroslav Svoboda
created an issue

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

java.lang.IllegalArgumentException: Sheet index (-1) is out of range (0..0)
    at HSSFWorkbook.validateSheetIndex(HSSFWorkbook.java:492)
    at HSSFWorkbook.getSheetName(HSSFWorkbook.java:629)
    at HSSFSheet.getSheetName(HSSFSheet.java:2052)
    at PoiTransformer.readCommentsFromSheet(PoiTransformer.java:286)
    at PoiTransformer.getCommentedCells(PoiTransformer.java:216)
    at XlsCommentAreaBuilder.build(XlsCommentAreaBuilder.java:132)

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

Comments (9)

  1. leonate NA repo owner

    I need a concrete example to reproduce it.

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

  2. leonate NA 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. leonate NA 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