getSheet() method in SheetPOI class always returns null

The getSheetName() method in the SheetPOI class always returns null, as the instance variable is never initialized.

However, the getSheetNames() method works as expected for the parent excel file.

Thanks.

Edit: Looks like I wasn’t the first to discover this:

The issue still exists nevertheless.

1 Like

Real easy fix here. Just init these in the constructor. Something like:

public SheetPOI(String sourceUrl, boolean hasHeaders, Workbook workbook) throws IOException {
    super(sourceUrl, hasHeaders);
    this.workbook = workbook;
    // Add these:
    this.sheet = workbook.getSheetAt(workbook.getActiveSheetIndex());
    this.sheetName = sheet.getSheetName();
}
3 Likes

Kudos, man.

(some required but unnecessary noise to defeat the 10 char min limit)

1 Like