Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promble when I set sheetName=“sheet1”,and download in browser is ok, but when I open it in my excel, it say my file contains some error #873

Closed
johnsGuo opened this issue Jul 9, 2021 · 3 comments

Comments

@johnsGuo
Copy link

johnsGuo commented Jul 9, 2021

Describe the results you received:
here is my test code

package utils

import (
	"fmt"
	"github.com/xuri/excelize/v2"
	"testing"
)

func TestExportExcelUtil(t *testing.T) {
	t.Run("", func(t *testing.T) {
		f := excelize.NewFile()
                // if set "Sheet1" the xlsx will open ok in Excel, only use "sheet1" occur error
		sheetIndex := f.NewSheet("sheet1")
		f.SetActiveSheet(sheetIndex)
		f.SaveAs("test1.xlsx")
	})
}

it's running ok, but the xlsx file may occur error when open in Excel
image

Environment

go version go1.15.6 darwin/amd64
with github.com/xuri/excelize/v2 v2.4.0

@xuri
Copy link
Member

xuri commented Jul 10, 2021

Thanks for your feedback, which version of Excelize are you using? I've tested and it works well. Could you provide more details, code to reproduce this issue or a spreadsheet xlsx attachment without confidential info?

@xuri xuri added the needs more info This issue can't reproduce, need more info label Jul 10, 2021
@johnsGuo
Copy link
Author

go version go1.15.6 darwin/amd64
excelize v2.4.0

you can use my demo code to test, only when I set SheetName='sheet1' occur this problem.

@xuri xuri removed the needs more info This issue can't reproduce, need more info label Jul 10, 2021
@xuri xuri closed this as completed in b14b74b Jul 10, 2021
@xuri
Copy link
Member

xuri commented Jul 10, 2021

Thanks for your issue, I have fixed this by letting the sheet names are not case sensitive for NewSheet, GetSheetIndex, DeleteSheet. Please try to upgrade the master branch code, and this feature will be released in the next version. When creating a new spreadsheet file, the default
worksheet named Sheet1 will be created, if you wanna change the name for it, you can using the SetSheetName.

jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
…or `NewSheet`, `GetSheetIndex`, `DeleteSheet`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants