@@ -236,13 +236,13 @@ func (f *File) setCellTimeFunc(sheet, cell string, value time.Time) error {
236
236
if err != nil {
237
237
return err
238
238
}
239
- c , col , row , err := f .prepareCell (ws , cell )
239
+ c , col , row , err := ws .prepareCell (cell )
240
240
if err != nil {
241
241
return err
242
242
}
243
- ws .Lock ()
244
- c .S = f .prepareCellStyle (ws , col , row , c .S )
245
- ws .Unlock ()
243
+ ws .mu . Lock ()
244
+ c .S = ws .prepareCellStyle (col , row , c .S )
245
+ ws .mu . Unlock ()
246
246
var date1904 , isNum bool
247
247
wb , err := f .workbookReader ()
248
248
if err != nil {
@@ -292,13 +292,13 @@ func (f *File) SetCellInt(sheet, cell string, value int) error {
292
292
if err != nil {
293
293
return err
294
294
}
295
- c , col , row , err := f .prepareCell (ws , cell )
295
+ c , col , row , err := ws .prepareCell (cell )
296
296
if err != nil {
297
297
return err
298
298
}
299
- ws .Lock ()
300
- defer ws .Unlock ()
301
- c .S = f .prepareCellStyle (ws , col , row , c .S )
299
+ ws .mu . Lock ()
300
+ defer ws .mu . Unlock ()
301
+ c .S = ws .prepareCellStyle (col , row , c .S )
302
302
c .T , c .V = setCellInt (value )
303
303
c .IS = nil
304
304
return f .removeFormula (c , ws , sheet )
@@ -318,13 +318,13 @@ func (f *File) SetCellBool(sheet, cell string, value bool) error {
318
318
if err != nil {
319
319
return err
320
320
}
321
- c , col , row , err := f .prepareCell (ws , cell )
321
+ c , col , row , err := ws .prepareCell (cell )
322
322
if err != nil {
323
323
return err
324
324
}
325
- ws .Lock ()
326
- defer ws .Unlock ()
327
- c .S = f .prepareCellStyle (ws , col , row , c .S )
325
+ ws .mu . Lock ()
326
+ defer ws .mu . Unlock ()
327
+ c .S = ws .prepareCellStyle (col , row , c .S )
328
328
c .T , c .V = setCellBool (value )
329
329
c .IS = nil
330
330
return f .removeFormula (c , ws , sheet )
@@ -355,13 +355,13 @@ func (f *File) SetCellFloat(sheet, cell string, value float64, precision, bitSiz
355
355
if err != nil {
356
356
return err
357
357
}
358
- c , col , row , err := f .prepareCell (ws , cell )
358
+ c , col , row , err := ws .prepareCell (cell )
359
359
if err != nil {
360
360
return err
361
361
}
362
- ws .Lock ()
363
- defer ws .Unlock ()
364
- c .S = f .prepareCellStyle (ws , col , row , c .S )
362
+ ws .mu . Lock ()
363
+ defer ws .mu . Unlock ()
364
+ c .S = ws .prepareCellStyle (col , row , c .S )
365
365
c .T , c .V = setCellFloat (value , precision , bitSize )
366
366
c .IS = nil
367
367
return f .removeFormula (c , ws , sheet )
@@ -381,13 +381,13 @@ func (f *File) SetCellStr(sheet, cell, value string) error {
381
381
if err != nil {
382
382
return err
383
383
}
384
- c , col , row , err := f .prepareCell (ws , cell )
384
+ c , col , row , err := ws .prepareCell (cell )
385
385
if err != nil {
386
386
return err
387
387
}
388
- ws .Lock ()
389
- defer ws .Unlock ()
390
- c .S = f .prepareCellStyle (ws , col , row , c .S )
388
+ ws .mu . Lock ()
389
+ defer ws .mu . Unlock ()
390
+ c .S = ws .prepareCellStyle (col , row , c .S )
391
391
if c .T , c .V , err = f .setCellString (value ); err != nil {
392
392
return err
393
393
}
@@ -413,8 +413,8 @@ func (f *File) setCellString(value string) (t, v string, err error) {
413
413
// sharedStringsLoader load shared string table from system temporary file to
414
414
// memory, and reset shared string table for reader.
415
415
func (f * File ) sharedStringsLoader () (err error ) {
416
- f .Lock ()
417
- defer f .Unlock ()
416
+ f .mu . Lock ()
417
+ defer f .mu . Unlock ()
418
418
if path , ok := f .tempFiles .Load (defaultXMLPathSharedStrings ); ok {
419
419
f .Pkg .Store (defaultXMLPathSharedStrings , f .readBytes (defaultXMLPathSharedStrings ))
420
420
f .tempFiles .Delete (defaultXMLPathSharedStrings )
@@ -443,8 +443,8 @@ func (f *File) setSharedString(val string) (int, error) {
443
443
if err != nil {
444
444
return 0 , err
445
445
}
446
- f .Lock ()
447
- defer f .Unlock ()
446
+ f .mu . Lock ()
447
+ defer f .mu . Unlock ()
448
448
if i , ok := f .sharedStringsMap [val ]; ok {
449
449
return i , nil
450
450
}
@@ -558,8 +558,8 @@ func (c *xlsxC) getCellDate(f *File, raw bool) (string, error) {
558
558
// intended to be used with for range on rows an argument with the spreadsheet
559
559
// opened file.
560
560
func (c * xlsxC ) getValueFrom (f * File , d * xlsxSST , raw bool ) (string , error ) {
561
- f .Lock ()
562
- defer f .Unlock ()
561
+ f .mu . Lock ()
562
+ defer f .mu . Unlock ()
563
563
switch c .T {
564
564
case "b" :
565
565
return c .getCellBool (f , raw )
@@ -600,13 +600,13 @@ func (f *File) SetCellDefault(sheet, cell, value string) error {
600
600
if err != nil {
601
601
return err
602
602
}
603
- c , col , row , err := f .prepareCell (ws , cell )
603
+ c , col , row , err := ws .prepareCell (cell )
604
604
if err != nil {
605
605
return err
606
606
}
607
- ws .Lock ()
608
- defer ws .Unlock ()
609
- c .S = f .prepareCellStyle (ws , col , row , c .S )
607
+ ws .mu . Lock ()
608
+ defer ws .mu . Unlock ()
609
+ c .S = ws .prepareCellStyle (col , row , c .S )
610
610
c .setCellDefault (value )
611
611
return f .removeFormula (c , ws , sheet )
612
612
}
@@ -718,7 +718,7 @@ func (f *File) SetCellFormula(sheet, cell, formula string, opts ...FormulaOpts)
718
718
if err != nil {
719
719
return err
720
720
}
721
- c , _ , _ , err := f .prepareCell (ws , cell )
721
+ c , _ , _ , err := ws .prepareCell (cell )
722
722
if err != nil {
723
723
return err
724
724
}
@@ -763,7 +763,7 @@ func (ws *xlsxWorksheet) setSharedFormula(ref string) error {
763
763
cnt := ws .countSharedFormula ()
764
764
for c := coordinates [0 ]; c <= coordinates [2 ]; c ++ {
765
765
for r := coordinates [1 ]; r <= coordinates [3 ]; r ++ {
766
- prepareSheetXML (ws , c , r )
766
+ ws . prepareSheetXML (c , r )
767
767
cell := & ws .SheetData .Row [r - 1 ].C [c - 1 ]
768
768
if cell .F == nil {
769
769
cell .F = & xlsxF {}
@@ -867,7 +867,7 @@ func (f *File) SetCellHyperLink(sheet, cell, link, linkType string, opts ...Hype
867
867
if err != nil {
868
868
return err
869
869
}
870
- if cell , err = f .mergeCellsParser (ws , cell ); err != nil {
870
+ if cell , err = ws .mergeCellsParser (cell ); err != nil {
871
871
return err
872
872
}
873
873
@@ -944,7 +944,7 @@ func (f *File) GetCellRichText(sheet, cell string) (runs []RichTextRun, err erro
944
944
if err != nil {
945
945
return
946
946
}
947
- c , _ , _ , err := f .prepareCell (ws , cell )
947
+ c , _ , _ , err := ws .prepareCell (cell )
948
948
if err != nil {
949
949
return
950
950
}
@@ -1171,14 +1171,14 @@ func (f *File) SetCellRichText(sheet, cell string, runs []RichTextRun) error {
1171
1171
if err != nil {
1172
1172
return err
1173
1173
}
1174
- c , col , row , err := f .prepareCell (ws , cell )
1174
+ c , col , row , err := ws .prepareCell (cell )
1175
1175
if err != nil {
1176
1176
return err
1177
1177
}
1178
1178
if err := f .sharedStringsLoader (); err != nil {
1179
1179
return err
1180
1180
}
1181
- c .S = f .prepareCellStyle (ws , col , row , c .S )
1181
+ c .S = ws .prepareCellStyle (col , row , c .S )
1182
1182
si := xlsxSI {}
1183
1183
sst , err := f .sharedStringsReader ()
1184
1184
if err != nil {
@@ -1252,9 +1252,9 @@ func (f *File) setSheetCells(sheet, cell string, slice interface{}, dir adjustDi
1252
1252
}
1253
1253
1254
1254
// getCellInfo does common preparation for all set cell value functions.
1255
- func (f * File ) prepareCell (ws * xlsxWorksheet , cell string ) (* xlsxC , int , int , error ) {
1255
+ func (ws * xlsxWorksheet ) prepareCell (cell string ) (* xlsxC , int , int , error ) {
1256
1256
var err error
1257
- cell , err = f .mergeCellsParser (ws , cell )
1257
+ cell , err = ws .mergeCellsParser (cell )
1258
1258
if err != nil {
1259
1259
return nil , 0 , 0 , err
1260
1260
}
@@ -1263,9 +1263,9 @@ func (f *File) prepareCell(ws *xlsxWorksheet, cell string) (*xlsxC, int, int, er
1263
1263
return nil , 0 , 0 , err
1264
1264
}
1265
1265
1266
- prepareSheetXML (ws , col , row )
1267
- ws .Lock ()
1268
- defer ws .Unlock ()
1266
+ ws . prepareSheetXML (col , row )
1267
+ ws .mu . Lock ()
1268
+ defer ws .mu . Unlock ()
1269
1269
return & ws .SheetData .Row [row - 1 ].C [col - 1 ], col , row , err
1270
1270
}
1271
1271
@@ -1277,7 +1277,7 @@ func (f *File) getCellStringFunc(sheet, cell string, fn func(x *xlsxWorksheet, c
1277
1277
if err != nil {
1278
1278
return "" , err
1279
1279
}
1280
- cell , err = f .mergeCellsParser (ws , cell )
1280
+ cell , err = ws .mergeCellsParser (cell )
1281
1281
if err != nil {
1282
1282
return "" , err
1283
1283
}
@@ -1286,8 +1286,8 @@ func (f *File) getCellStringFunc(sheet, cell string, fn func(x *xlsxWorksheet, c
1286
1286
return "" , err
1287
1287
}
1288
1288
1289
- ws .Lock ()
1290
- defer ws .Unlock ()
1289
+ ws .mu . Lock ()
1290
+ defer ws .mu . Unlock ()
1291
1291
1292
1292
lastRowNum := 0
1293
1293
if l := len (ws .SheetData .Row ); l > 0 {
@@ -1366,7 +1366,7 @@ func (f *File) formattedValue(c *xlsxC, raw bool, cellType CellType) (string, er
1366
1366
1367
1367
// prepareCellStyle provides a function to prepare style index of cell in
1368
1368
// worksheet by given column index and style index.
1369
- func (f * File ) prepareCellStyle (ws * xlsxWorksheet , col , row , style int ) int {
1369
+ func (ws * xlsxWorksheet ) prepareCellStyle (col , row , style int ) int {
1370
1370
if style != 0 {
1371
1371
return style
1372
1372
}
@@ -1387,7 +1387,7 @@ func (f *File) prepareCellStyle(ws *xlsxWorksheet, col, row, style int) int {
1387
1387
1388
1388
// mergeCellsParser provides a function to check merged cells in worksheet by
1389
1389
// given cell reference.
1390
- func (f * File ) mergeCellsParser (ws * xlsxWorksheet , cell string ) (string , error ) {
1390
+ func (ws * xlsxWorksheet ) mergeCellsParser (cell string ) (string , error ) {
1391
1391
cell = strings .ToUpper (cell )
1392
1392
col , row , err := CellNameToCoordinates (cell )
1393
1393
if err != nil {
0 commit comments