qax-os / excelize

Go language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets
https://xuri.me/excelize
BSD 3-Clause "New" or "Revised" License
17.62k stars 1.68k forks source link

WriteToBuffer function takes too long times #1900

Closed xiaozhiliaoo closed 1 month ago

xiaozhiliaoo commented 1 month ago

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 commented 1 month ago

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.