excelize
excelize copied to clipboard
Unable to fetch rows of a sheet with more than 31 characters in its name.
Description Unable to fetch a sheet with more than 31 characters in its name.
I know this is not supported by Microsoft Excel but this issue prevents a user from handling xlsx files produced by other tools (LibreOffice or Google Sheets).
The reason for this is in File.Rows() when getting the sheet from f.sheetMap (see github.com/360EntSecGroup-Skylar/excelize/rows.go:151).
The problem here is that f.sheetMap has the original sheet name but we're trying to find it via the truncated sheet name (trimSheetName(sheet)). Naturally, this may not be possible when the sheet name doesn't respect the 31 character limit.
#249 mentions something about 31 characters, but I don't understand Chinese so I cannot be sure if it's related at all.
Steps to reproduce the issue:
- Download this zip
- Extract the
xlsxand thegofile. - Run the go file:
go run main.go
Describe the results you received: Excelize cannot find the sheet "abcdefghijklmnopqrstuvwxyz0123456789"
$ go run main.go
Err is nil: false
sheet abcdefghijklmnopqrstuvwxyz0123456789 is not exist
Describe the results you expected: I expected the sheet "abcdefghijklmnopqrstuvwxyz0123456789" to be found.
$ go run main.go
Err is nil: true
nil
Output of go version:
go version go1.13.5 linux/amd64
Excelize version or commit ID:
5f3a4bc39f9cf2987104ffe57242a0526cdd9158
Environment details (OS, Microsoft Excel™ version, physical, etc.): Linux
Hi @dosaki, thanks for your feedback. I propose keeping the 31-character limit to prevent mostly unexpected file corruption, use abbreviations for words in the names, devise a code-number system that ties to a longer name listed in a worksheet, etc.
I don't think getting rid of the 31 character limit is a good solution but if the sheet map is also capped to 31 characters then this would resolve the issue?
Currently, if you save or export the workbook by LibreOffice (7.5.2.2) and Google Sheets, the sheet name of more than 31 characters will be trimmed, so I think we need to keep this maximum limit for better compatibility. I've closed this issue, if you have any questions, please me know, and we can reopen this anytime.