summaryrefslogtreecommitdiff
path: root/styles.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2021-07-07 00:57:43 +0800
committerxuri <xuri.me@gmail.com>2021-07-07 00:57:43 +0800
commit90d200a10ba4d8c2ae2eff47ad8e1cca0ab28e76 (patch)
tree7579365b99b61562404ced4d71058b917b92f003 /styles.go
parentb7fece51736977e7d84aca30ecce7f6b3a1251f2 (diff)
Make the functions `SetSheetRow`, `New Style` and `SetCellStyle` concurrency safety
Diffstat (limited to 'styles.go')
-rw-r--r--styles.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/styles.go b/styles.go
index 235746c..5b9b200 100644
--- a/styles.go
+++ b/styles.go
@@ -1990,6 +1990,8 @@ func (f *File) NewStyle(style interface{}) (int, error) {
fs.DecimalPlaces = 2
}
s := f.stylesReader()
+ s.Lock()
+ defer s.Unlock()
// check given style already exist.
if cellXfsID = f.getStyleID(s, fs); cellXfsID != -1 {
return cellXfsID, err
@@ -2693,7 +2695,8 @@ func (f *File) SetCellStyle(sheet, hcell, vcell string, styleID int) error {
}
prepareSheetXML(ws, vcol, vrow)
makeContiguousColumns(ws, hrow, vrow, vcol)
-
+ ws.Lock()
+ defer ws.Unlock()
for r := hrowIdx; r <= vrowIdx; r++ {
for k := hcolIdx; k <= vcolIdx; k++ {
ws.SheetData.Row[r].C[k].S = styleID