Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Excelize
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Globars Forks
Excelize
Commits
0dd616b1
Unverified
Commit
0dd616b1
authored
May 22, 2020
by
xuri
Committed by
GitHub
May 22, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #517 from hengmyj/fix/cell_lock
make set cell value is concurrency safe
parents
2efc7107
ec14de32
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
0 deletions
+13
-0
cell.go
cell.go
+13
-0
No files found.
cell.go
View file @
0dd616b1
...
...
@@ -16,6 +16,7 @@ import (
"reflect"
"strconv"
"strings"
"sync"
"time"
)
...
...
@@ -30,6 +31,8 @@ const (
STCellFormulaTypeShared
=
"shared"
)
var
rwMutex
sync
.
RWMutex
// GetCellValue provides a function to get formatted value from cell by given
// worksheet name and axis in XLSX file. If it is possible to apply a format
// to the cell value, it will do so, if not then an error will be returned,
...
...
@@ -179,6 +182,8 @@ func setCellDuration(value time.Duration) (t string, v string) {
// SetCellInt provides a function to set int type value of a cell by given
// worksheet name, cell coordinates and cell value.
func
(
f
*
File
)
SetCellInt
(
sheet
,
axis
string
,
value
int
)
error
{
rwMutex
.
Lock
()
defer
rwMutex
.
Unlock
()
xlsx
,
err
:=
f
.
workSheetReader
(
sheet
)
if
err
!=
nil
{
return
err
...
...
@@ -200,6 +205,8 @@ func setCellInt(value int) (t string, v string) {
// SetCellBool provides a function to set bool type value of a cell by given
// worksheet name, cell name and cell value.
func
(
f
*
File
)
SetCellBool
(
sheet
,
axis
string
,
value
bool
)
error
{
rwMutex
.
Lock
()
defer
rwMutex
.
Unlock
()
xlsx
,
err
:=
f
.
workSheetReader
(
sheet
)
if
err
!=
nil
{
return
err
...
...
@@ -233,6 +240,8 @@ func setCellBool(value bool) (t string, v string) {
// f.SetCellFloat("Sheet1", "A1", float64(x), 2, 32)
//
func
(
f
*
File
)
SetCellFloat
(
sheet
,
axis
string
,
value
float64
,
prec
,
bitSize
int
)
error
{
rwMutex
.
Lock
()
defer
rwMutex
.
Unlock
()
xlsx
,
err
:=
f
.
workSheetReader
(
sheet
)
if
err
!=
nil
{
return
err
...
...
@@ -254,6 +263,8 @@ func setCellFloat(value float64, prec, bitSize int) (t string, v string) {
// SetCellStr provides a function to set string type value of a cell. Total
// number of characters that a cell can contain 32767 characters.
func
(
f
*
File
)
SetCellStr
(
sheet
,
axis
,
value
string
)
error
{
rwMutex
.
Lock
()
defer
rwMutex
.
Unlock
()
xlsx
,
err
:=
f
.
workSheetReader
(
sheet
)
if
err
!=
nil
{
return
err
...
...
@@ -327,6 +338,8 @@ type FormulaOpts struct {
// SetCellFormula provides a function to set cell formula by given string and
// worksheet name.
func
(
f
*
File
)
SetCellFormula
(
sheet
,
axis
,
formula
string
,
opts
...
FormulaOpts
)
error
{
rwMutex
.
Lock
()
defer
rwMutex
.
Unlock
()
xlsx
,
err
:=
f
.
workSheetReader
(
sheet
)
if
err
!=
nil
{
return
err
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment