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

WriteToBuffer function takes too long times #1900

Closed
xiaozhiliaoo opened this issue May 20, 2024 · 1 comment
Closed

WriteToBuffer function takes too long times #1900

xiaozhiliaoo opened this issue May 20, 2024 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@xiaozhiliaoo
Copy link

Description

f := excelize.NewFile()
	sheet := "sheet1"
	_ = f.SetSheetName("Sheet1", sheet)
	for x, row := range rows {
		for y, cell := range row {
			cellName, err := excelize.CoordinatesToCellName(y+1, x+1)
			if err != nil {
				continue
			}
			if err := f.SetCellStr(sheet, cellName, cell); err != nil {
				continue
			}
		}
	}
	bs, err := f.WriteToBuffer()

4核8G的配置,文件差不多有16.3M,9000行左右, f.WriteToBuffer()耗时有30s左右,请问下有没有优化方法,让WriteToBuffer更快呢?

Steps to reproduce the issue:
1.
2.
3.

Describe the results you received:

Describe the results you expected:

Output of go version:

(paste your output here)

Excelize version or commit ID:

(paste here)

Environment details (OS, Microsoft Excel™ version, physical, etc.):

@xuri
Copy link
Member

xuri commented May 20, 2024

Thanks for your issue. If you are reporting a new issue, make sure that we do not have any duplicates that already exist. This was duplicated with issues #20, #29, #364, #382, #406, #1100, #1106 and #1551, please using stream writer for generating a new worksheet with massive amounts of data. Here are some performance figures for your reference: Performance Figures, please try using the last version. I've closed this issue. If you have any questions, please let me know, and you can reopen this anytime.

@xuri xuri closed this as completed May 20, 2024
@xuri xuri added the duplicate This issue or pull request already exists label May 20, 2024
@xuri xuri changed the title WriteToBuffer耗时过久问题 WriteToBuffer function takes too long times May 20, 2024
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