From 75ce2317286181e2c250c10206df892278d5b981 Mon Sep 17 00:00:00 2001 From: xuri Date: Thu, 1 Sep 2022 00:41:52 +0800 Subject: This closes #1323, an error will be returned when set the not exist style ID --- styles.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'styles.go') diff --git a/styles.go b/styles.go index 55ee175..87c4863 100644 --- a/styles.go +++ b/styles.go @@ -2629,6 +2629,14 @@ func (f *File) SetCellStyle(sheet, hCell, vCell string, styleID int) error { makeContiguousColumns(ws, hRow, vRow, vCol) ws.Lock() defer ws.Unlock() + + s := f.stylesReader() + s.Lock() + defer s.Unlock() + if styleID < 0 || s.CellXfs == nil || len(s.CellXfs.Xf) <= styleID { + return newInvalidStyleID(styleID) + } + for r := hRowIdx; r <= vRowIdx; r++ { for k := hColIdx; k <= vColIdx; k++ { ws.SheetData.Row[r].C[k].S = styleID -- cgit v1.2.1