From 317ef65381b179b863dcd6b1f5479cc576a8376c Mon Sep 17 00:00:00 2001 From: mbresson Date: Fri, 19 Jan 2018 17:32:54 +0800 Subject: make SetCellStyle quicker by skipping conversions in checkCellInArea, and skipping area checks when we are sure the cell can't be before or past the current row/col Signed-off-by: Matthieu Bresson --- styles.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'styles.go') diff --git a/styles.go b/styles.go index 87bca13..8cee5ff 100644 --- a/styles.go +++ b/styles.go @@ -2327,7 +2327,19 @@ func (f *File) SetCellStyle(sheet, hcell, vcell string, styleID int) { completeCol(xlsx, vyAxis+1, vxAxis+1) for r, row := range xlsx.SheetData.Row { + if r < hyAxis { + continue + } else if r > vyAxis { + break + } + for k, c := range row.C { + if k < hxAxis { + continue + } else if k > vxAxis { + break + } + if checkCellInArea(c.R, hcell+":"+vcell) { xlsx.SheetData.Row[r].C[k].S = styleID } -- cgit v1.2.1