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

Example doesn't work in Go 1.9 #120

Closed
crosslogic opened this issue Sep 12, 2017 · 2 comments
Closed

Example doesn't work in Go 1.9 #120

crosslogic opened this issue Sep 12, 2017 · 2 comments

Comments

@crosslogic
Copy link

So, I've tried this:

func ExportarExcel(path string) error {
	file := excelize.NewFile()
	detalle := "Detalle"
	file.NewSheet(2, detalle)
	file.SetCellValue(detalle, "A1", "ID")
	file.SetActiveSheet(2)
	err := file.SaveAs(path)
	if err != nil {
		log.Fatal(err)
	}

	return nil
}

I get a file with the sheet created but has nothing in A1 cell. None error is returned.

salida.xlsx

xuri added a commit that referenced this issue Sep 13, 2017
@xuri
Copy link
Member

xuri commented Sep 13, 2017

Thanks for your issue. I have fixed this issue by use worksheet name instead of "sheet" + index, related issue #25, #43, #47, #51, #89, #101 and #116. Note that the params of function NewSheet() also has been changed, please adjust your code like this:

func ExportarExcel(path string) error {
    file := excelize.NewFile()
    detalle := "Detalle"
    index := file.NewSheet(detalle)
    file.SetCellValue(detalle, "A1", "ID")
    file.SetActiveSheet(index)
    err := file.SaveAs(path)
    if err != nil {
        log.Fatal(err)
    }
    return nil
}

@zzc-tongji
Copy link

Oh!
You change the API!
That's why my program doesn't work correctly!

@xuri xuri closed this as completed Sep 2, 2018
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

3 participants