-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Description
Description
GetSheetName doesn't work on this excel (other excels are no problem)
GetSheetName.xlsx
func ReadExcelFile(){
f, err := excelize.OpenFile("./GetSheetName.xlsx")
if err != nil {
Println(err)
return
}
fmt.Println(f.GetSheetName(1))
}
Steps to reproduce the issue:
1.Open the excel and read it and you can find it can't get the result "Sheet1",it got a empty string
Output of go version
:
1.12.7
Excelize version or commit ID:
2019.08.04 update github
Environment details (OS, Microsoft Excel™ version, physical, etc.):
win10 1903
office 2019(but i don't know who create this excel and his excel version, it's on our svn)
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
mlh758 commentedon Aug 6, 2019
This opens fine for me on MacOS.
"./GetSheetName.xlsx"
doesn't look like valid path syntax on Windows.EP-Toushirou commentedon Aug 7, 2019
you can test it on windows, other excels are no problem, but i don't know why this excel cannot get the sheet name. @mlh758
mlh758 commentedon Aug 7, 2019
Okay yeah I can reproduce this.
GetSheetName
looks for a sheet with an ID that matches the index. This presumably assumes that the IDs on the sheets are in order. The only sheet in this excel document has an ID of 5.mlh758 commentedon Aug 7, 2019
It looks like changing the sheet order changes the order sheets appear within the
<sheets>
tag withinworkbook.xml
. @xuri I thinkGetSheetName
can be simplified to just check the index of the sheet against theSheets
field in a workbook.mlh758 commentedon Aug 7, 2019
Go ahead and pull down the code from this PR and let me know if that fixes your issue.
EP-Toushirou commentedon Aug 7, 2019
@mlh758 yes, it can slove the problem.thank you.
Get sheet names based on index