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

XLSX file is coming empty but when I repair it is coming fine #1623

Closed
lakshy-amagi opened this issue Aug 23, 2023 · 10 comments
Closed

XLSX file is coming empty but when I repair it is coming fine #1623

lakshy-amagi opened this issue Aug 23, 2023 · 10 comments
Labels
duplicate This issue or pull request already exists

Comments

@lakshy-amagi
Copy link

Description
I am using github.com/xuri/excelize/v2 v2.7.1
To create the xlsx file

I used simple code

`package main

import (
"fmt"

"github.com/xuri/excelize/v2"

)

func main() {
f := excelize.NewFile()
defer func() {
if err := f.Close(); err != nil {
fmt.Println(err)
}
}()
// Create a new sheet.
index, err := f.NewSheet("Sheet2")
if err != nil {
fmt.Println(err)
return
}
// Set value of a cell.
f.SetCellValue("Sheet2", "A2", "Hello world.")
f.SetCellValue("Sheet1", "B2", 100)
// Set active sheet of the workbook.
f.SetActiveSheet(index)
// Save spreadsheet by the given path.
if err := f.SaveAs("./Book1.xlsx"); err != nil {
fmt.Println(err)
}
}`

But when I open the xlsx file (Books.xlsx) it comes up empty
image

If I try to repair the xlsx file then data is coming
image

OS - ubuntu
Go version - go version go1.21.0 linux/amd64

I updated the github.com/xuri/excelize/v2 to latest version v2.7.1

For your reference my go.mod
`module excelize

go 1.21.0

require github.com/xuri/excelize/v2 v2.7.1

require (
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/richardlehane/mscfb v1.0.4 // indirect
github.com/richardlehane/msoleps v1.0.3 // indirect
github.com/xuri/efp v0.0.0-20230802181842-ad255f2331ca // indirect
github.com/xuri/nfp v0.0.0-20230819163627-dc951e3ffe1a // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/text v0.12.0 // indirect
)
`

@lakshy-amagi
Copy link
Author

Description I am using github.com/xuri/excelize/v2 v2.7.1 To create the xlsx file

I used simple code

`package main

import ( "fmt"

"github.com/xuri/excelize/v2"

)

func main() { f := excelize.NewFile() defer func() { if err := f.Close(); err != nil { fmt.Println(err) } }() // Create a new sheet. index, err := f.NewSheet("Sheet2") if err != nil { fmt.Println(err) return } // Set value of a cell. f.SetCellValue("Sheet2", "A2", "Hello world.") f.SetCellValue("Sheet1", "B2", 100) // Set active sheet of the workbook. f.SetActiveSheet(index) // Save spreadsheet by the given path. if err := f.SaveAs("./Book1.xlsx"); err != nil { fmt.Println(err) } }`

But when I open the xlsx file (Books.xlsx) it comes up empty image

If I try to repair the xlsx file then data is coming image

OS - ubuntu Go version - go version go1.21.0 linux/amd64

I updated the github.com/xuri/excelize/v2 to latest version v2.7.1

For your reference my go.mod `module excelize

go 1.21.0

require github.com/xuri/excelize/v2 v2.7.1

require ( github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/richardlehane/mscfb v1.0.4 // indirect github.com/richardlehane/msoleps v1.0.3 // indirect github.com/xuri/efp v0.0.0-20230802181842-ad255f2331ca // indirect github.com/xuri/nfp v0.0.0-20230819163627-dc951e3ffe1a // indirect golang.org/x/crypto v0.12.0 // indirect golang.org/x/net v0.14.0 // indirect golang.org/x/text v0.12.0 // indirect ) `

I also changed the go version to 1.20.7 still getting the same error

@gengxun
Copy link

gengxun commented Aug 24, 2023

the same issues ,golang v1.21

@xuri
Copy link
Member

xuri commented Aug 24, 2023

the same issues ,golang v1.21

@gengxun, there are some incompatible changes in the Go 1.21.0 encoding/xml library. I have given feedback to the Go team and created a patch for it (golang/go#61881). I suggest waiting for the next Go 1.21.1 minor releases or using the Go 1.20.7 or previous version. Also reference issues #1465, #1595, #1603, #1608, #1614, #1619 and #1620.

@xuri
Copy link
Member

xuri commented Aug 24, 2023

@lakshy-amagi, I've tested with LibreOffice 7.3.7.2, Ubuntu 22.04.1 LTS, and it works well. Please check and make sure your Go version was not 1.21.0. There are any more info to reproduce this issue?

@xuri xuri added the needs more info This issue can't reproduce, need more info label Aug 24, 2023
@lakshy-amagi
Copy link
Author

@lakshy-amagi, I've tested with LibreOffice 7.3.7.2, Ubuntu 22.04.1 LTS, and it works well. Please check and make sure your Go version was not 1.21.0. There are any more info to reproduce this issue?

Thanks, @xuri for the fast response in local I changed the version to 1.20.7 it did the trick but need to check whether it will work in my production. I will let you know if it works until then please don't close this ticket.

@stvoidit
Copy link

I confirm the problem. I was unpleasantly surprised to see empty sheets.

  • 1.20.6 - OK
  • 1.20.7 -OK
  • 1.21.0 - FAIL, empty sheets

@xuri
Copy link
Member

xuri commented Aug 29, 2023

@stvoidit There are some incompatible changes in the Go 1.21.0 encoding/xml library. I have given feedback to the Go team and created a patch for it golang/go#61881, and the Go team has added golang/go#62051 to the Go 1.21.1 milestone. I suggest using the Go 1.20.7 and previous Go released version or waiting for the next Go minor releases.

@xuri xuri added duplicate This issue or pull request already exists and removed needs more info This issue can't reproduce, need more info labels Aug 29, 2023
@stvoidit
Copy link

@stvoidit There are some incompatible changes in the Go 1.21.0 encoding/xml library. I have given feedback to the Go team and created a patch for it golang/go#61881, and the Go team has added golang/go#62051 to the Go 1.21.1 milestone. I suggest using the Go 1.20.7 and previous Go released version or waiting for the next Go minor releases.

Good news! I am glad that there will already be a fix in the next patch. Thank you very much.

@xuri
Copy link
Member

xuri commented Aug 30, 2023

Hi @lakshy-amagi, it seems still not have enough info or feedback to reproduce this issue, so I'll close this issue, if you have any questions, please let me know to reopen this anytime.

@xuri xuri closed this as completed Aug 30, 2023
@lakshy-amagi
Copy link
Author

Hi @lakshy-amagi, it seems still not have enough info or feedback to reproduce this issue, so I'll close this issue, if you have any questions, please let me know to reopen this anytime.

Sorry @xuri for the late response I just deployed it yesterday it is working fine with the golang version 1.20.7.
Thanks for the help!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants