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

The file size increases abnormally when saving #1383

Closed
seanliang opened this issue Nov 2, 2022 · 2 comments
Closed

The file size increases abnormally when saving #1383

seanliang opened this issue Nov 2, 2022 · 2 comments
Labels
confirmed This issue can be reproduced

Comments

@seanliang
Copy link
Contributor

The original file size is 8KB, and it contains nothing but only one empty row (row# 1048576), the file size will become 2.8MB when saving.
origin.xlsx

Unzipped both files and you can find that the file size of sheet1.xml has increased from 1KB to 23MB.

package main

import (
	"log"
	"os"

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

func main() {
	fi, err := os.Stat("origin.xlsx")
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("Origin file size: %v", fi.Size())
	file, _ := excelize.OpenFile("origin.xlsx")
	file.SetCellValue("Test", "A1", "test")
	file.SaveAs("copy.xlsx")
	fi, _ = os.Stat("copy.xlsx")
	log.Printf("Copy file size: %v", fi.Size())
}

The output is

Origin file size: 8382
Copy file size: 2759163
@xuri xuri added confirmed This issue can be reproduced in progress Working in progress labels Nov 2, 2022
@xuri xuri closed this as completed in 4998b7b Nov 2, 2022
@xuri xuri removed the in progress Working in progress label Nov 3, 2022
@xuri
Copy link
Member

xuri commented Nov 3, 2022

Thanks for your issue, I have fixed it. Please upgrade to the master branch code, and this patch will be released in the next version.

@seanliang
Copy link
Contributor Author

Awesome! Thanks for your efforts!

xuri added a commit to JDavidVR/excelize that referenced this issue Jul 11, 2023
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed This issue can be reproduced
Projects
None yet
Development

No branches or pull requests

2 participants