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

Preserve existing style and format #1672

Closed
speix opened this issue Sep 24, 2023 · 3 comments
Closed

Preserve existing style and format #1672

speix opened this issue Sep 24, 2023 · 3 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@speix
Copy link

speix commented Sep 24, 2023

It would be nice to support opening and preserving the styles and formatting of a xlsx file, that is already formatted.
Example use-case: existing xlsx file, already formatted, and just want to fill it with values.

When I do that now, by simply using OpenFile/Save, my style is not preserved (pictures, titles, indentation and so on).
I get the error below:
"We found a problem with some content in ’test.xlsx’. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes."

Please, let me know if this is supported and I've missed it in the documentation.

@xuri
Copy link
Member

xuri commented Sep 24, 2023

Thanks for your issue. Which version of the Go language and Excelize library are you using? Could you follow the issue template and show us a complete, standalone example program or reproducible demo?

@xuri xuri added the needs more info This issue can't reproduce, need more info label Sep 24, 2023
@speix
Copy link
Author

speix commented Sep 24, 2023

Go version: 1.20.4 darwin/amd64 but I'm also targeting arm.
Excelize Lib: v2.8.0

Samples xlsx below, nothing fancy:
sample.xlsx

Code below (just a simple SaveAs a different name):

report, err := excelize.OpenFile("sample.xlsx")
	if err != nil {
		log.Fatal(err)
		return
	}
	defer func() {
		if err := report.Close(); err != nil {
			fmt.Println(err)
		}
	}()

if err := report.SaveAs("test.xlsx"); err != nil {
		log.Fatal(err)
	}

Trying to open the tests.xlsx gives me an excel spreadsheet with no styling and the warning message: "We found a problem with some content in ’test.xlsx’. Do you want us to try to recover as much as we can? If you trust the source of this workbook, click Yes."

@xuri
Copy link
Member

xuri commented Sep 24, 2023

Thanks for your feedback. This problem has been fixed, duplicated with #1666. Please upgrade to the master branch code, and this patch will be release in the next version.

@xuri xuri added bug Something isn't working and removed needs more info This issue can't reproduce, need more info labels Sep 24, 2023
@xuri xuri closed this as completed Sep 24, 2023
@xuri xuri added the duplicate This issue or pull request already exists label Sep 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants