Skip to content

GetSheetName doesn't work on this excel #457

@EP-Toushirou

Description

@EP-Toushirou

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)

Activity

mlh758

mlh758 commented on Aug 6, 2019

@mlh758
Contributor

This opens fine for me on MacOS. "./GetSheetName.xlsx" doesn't look like valid path syntax on Windows.

EP-Toushirou

EP-Toushirou commented on Aug 7, 2019

@EP-Toushirou
Author

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

mlh758 commented on Aug 7, 2019

@mlh758
Contributor

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

mlh758 commented on Aug 7, 2019

@mlh758
Contributor

It looks like changing the sheet order changes the order sheets appear within the <sheets> tag within workbook.xml. @xuri I think GetSheetName can be simplified to just check the index of the sheet against the Sheets field in a workbook.

mlh758

mlh758 commented on Aug 7, 2019

@mlh758
Contributor

Go ahead and pull down the code from this PR and let me know if that fixes your issue.

EP-Toushirou

EP-Toushirou commented on Aug 7, 2019

@EP-Toushirou
Author

@mlh758 yes, it can slove the problem.thank you.

added a commit that references this issue on Oct 23, 2020
1e21e7c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @mlh758@EP-Toushirou

      Issue actions

        GetSheetName doesn't work on this excel · Issue #457 · qax-os/excelize