-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Feature-request for batch merging cells #1221
Comments
Thanks for your feedback. The performance data is generated by this benchmark testing script, and I've test it works well. Can you show us a complete, standalone example program or reproducible demo? |
e , please use this test demo |
There is no obvious improvements in the time cost of the two programs in the attachment, and it takes about 1s to merge 400,000 cells not as you above mentation 1000s. |
think you, when i use this commit fix this problem |
性能说明:https://xuri.me/wp-content/uploads/2016/08/excelize-performance.svg?t=20220502中描述MergeCell的耗时为0.018
我这边在V2.6.0版本上实测两个单元格合并单次调用的确耗时很低,在0.001左右。
但是我们这边有个处理要求合并多个单元格。数量级在 8000行40列0.001S中
实测发现随着调用次数增多,单次调用耗时会有比较大的出入,我观察到最多可能会到0.008S左右。
整体全部跑下来,执行时间大约在1000S左右。
我在merge.go中另外写了一个批量处理MergeCell的func,耗时降到了12S
`
func (f *File) MergeCellUnSetStyle(sheet string, hCells, vCells []string) error {
ws, err := f.workSheetReader(sheet)
if err != nil {
return err
}
if len(hCells) != len(vCells) {
return newerr
}
for i := 0; i < len(hCells); i++ {
hCell := hCells[i]
vCell := vCells[i]
rect, err := areaRefToCoordinates(hCell + ":" + vCell)
if err != nil {
return err
}
// Correct the coordinate area, such correct C1:B3 to B1:C3.
// _ = sortCoordinates(rect)
//hCell, _ = CoordinatesToCellName(rect[0], rect[1])
//vCell, _ = CoordinatesToCellName(rect[2], rect[3])
ref := hCell + ":" + vCell
if ws.MergeCells != nil {
ws.MergeCells.Cells = append(ws.MergeCells.Cells, &xlsxMergeCell{Ref: ref, rect: rect})
} else {
ws.MergeCells = &xlsxMergeCells{Cells: []*xlsxMergeCell{{Ref: ref, rect: rect}}}
}
}
ws.MergeCells.Count = len(ws.MergeCells.Cells)
return nil
}
`
测试文件请查收附件,很抱歉无法提供带有数据的表格,附件为处理完毕的表格。
Hello 2022-05-06 08-40-09.xlsx
The text was updated successfully, but these errors were encountered: