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

Reading and saving a file corrupts it #1779

Closed
nlassaux opened this issue Jan 10, 2024 · 2 comments
Closed

Reading and saving a file corrupts it #1779

nlassaux opened this issue Jan 10, 2024 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@nlassaux
Copy link

Description

Opening the file linked below and saving it directly corrupts it. Opening it in Excel then removes all styles

Steps to reproduce the issue:

  1. Read the file and save it as a new one
  2. The new file is broken
package main

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

// in the main, we just open a file and save it
// to see if it corrupts it

func main() {
	f, err := excelize.OpenFile("WorkingFile.xlsx")
	if err != nil {
		panic(err)
	}
	if err := f.SaveAs("BreakingFile.xlsx"); err != nil {
		panic(err)
	}
}

WorkingFile.xlsx
BreakingFile.xlsx

Describe the results you received:
Excel must repair the file, removing all styles. From the error message the error is on /xl/styles.xml (HRESULT 0x8000ffff Line 2, Col 0)

Describe the results you expected:
The same document, +- some size differences due to different XML formatting.

Output of go version:

go version go1.21.3 darwin/amd64

Excelize version or commit ID:

github.com/xuri/excelize/v2 v2.8.0

Environment details (OS, Microsoft Excel™ version, physical, etc.):
On a Macbook Pro Intel. Using Excel Online for my tests but apparently the same with Excel running on Windows.

@xuri
Copy link
Member

xuri commented Jan 10, 2024

Thanks for your issue. This issue similar with #1653 and #1693, and already has been fixed, please upgrade to the master branch by go get -u github.com/xuri/excelize/v2@master, and this patch will be released in the next version.

@xuri xuri added the duplicate This issue or pull request already exists label Jan 10, 2024
@nlassaux
Copy link
Author

It worked well, thanks!

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

2 participants