Skip to content
This repository was archived by the owner on Aug 13, 2025. It is now read-only.
This repository was archived by the owner on Aug 13, 2025. It is now read-only.

Panic when opening a xlsx file with a sheet name longer than 31 characters. #848

@mrivottigym

Description

@mrivottigym

Hello, there is a panic when opening a xlsx file with a sheet name longer than 31 characters.

This is happening in the method readSheetsFromZipFile, when trying to access a nil sheet.Sheet in the following line:
sheetName := sheet.Sheet.Name

I have a couple of questions regarding this issue. The first one is if this should panic at all, or should it return an error saying that the sheet name is invalid when opening the file with OpenBinary.

My suggestion would be to check if sheet.Sheet != nil before accessing sheetName := sheet.Sheet.Name, so that the caller can handle the error and avoid crashing the application with a panic, like this:

if sheet.Sheet != nil {
	sheetName := sheet.Sheet.Name
	sheetsByName[sheetName] = sheet.Sheet
	sheets[sheet.Index] = sheet.Sheet
}

This would return an error like: ReadZipReader: {SheetIndex: 0} readSheetFromFile: sheet name is invalid: sheet name must be 31 or fewer characters long. It is currently '43' characters long

Another question is related to the limitation of the sheet name length. I understand that the Excel UI limits the sheet name length to 31 chars, but the file format allows up to 255 chars. So if someone doesn't use the UI like in my case, is it possible to bypass this limitation so that a length bigger than 31 chars doesn't return an error?

Thanks in advance, and thank you for your work on this lib.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions