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
c168233e
Unverified
Commit
c168233e
authored
May 27, 2020
by
xuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
speedup get cell value from shared string table
parent
5c99300e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
4 deletions
+10
-4
cell.go
cell.go
+3
-4
excelize.go
excelize.go
+2
-0
rows.go
rows.go
+5
-0
No files found.
cell.go
View file @
c168233e
...
...
@@ -299,14 +299,13 @@ func (f *File) setCellString(value string) (t string, v string, ns xml.Attr) {
// setSharedString provides a function to add string to the share string table.
func
(
f
*
File
)
setSharedString
(
val
string
)
int
{
sst
:=
f
.
sharedStringsReader
()
for
i
,
si
:=
range
sst
.
SI
{
if
si
.
T
==
val
{
return
i
}
if
i
,
ok
:=
f
.
sharedStringsMap
[
val
];
ok
{
return
i
}
sst
.
Count
++
sst
.
UniqueCount
++
sst
.
SI
=
append
(
sst
.
SI
,
xlsxSI
{
T
:
val
})
f
.
sharedStringsMap
[
val
]
=
sst
.
UniqueCount
-
1
return
sst
.
UniqueCount
-
1
}
...
...
excelize.go
View file @
c168233e
...
...
@@ -38,6 +38,7 @@ type File struct {
Drawings
map
[
string
]
*
xlsxWsDr
Path
string
SharedStrings
*
xlsxSST
sharedStringsMap
map
[
string
]
int
Sheet
map
[
string
]
*
xlsxWorksheet
SheetCount
int
Styles
*
xlsxStyleSheet
...
...
@@ -75,6 +76,7 @@ func newFile() *File {
sheetMap
:
make
(
map
[
string
]
string
),
Comments
:
make
(
map
[
string
]
*
xlsxComments
),
Drawings
:
make
(
map
[
string
]
*
xlsxWsDr
),
sharedStringsMap
:
make
(
map
[
string
]
int
),
Sheet
:
make
(
map
[
string
]
*
xlsxWorksheet
),
DecodeVMLDrawing
:
make
(
map
[
string
]
*
decodeVmlDrawing
),
VMLDrawing
:
make
(
map
[
string
]
*
vmlDrawing
),
...
...
rows.go
View file @
c168233e
...
...
@@ -292,6 +292,11 @@ func (f *File) sharedStringsReader() *xlsxSST {
log
.
Printf
(
"xml decode error: %s"
,
err
)
}
f
.
SharedStrings
=
&
sharedStrings
for
i
:=
range
sharedStrings
.
SI
{
if
sharedStrings
.
SI
[
i
]
.
T
!=
""
{
f
.
sharedStringsMap
[
sharedStrings
.
SI
[
i
]
.
T
]
=
i
}
}
f
.
addContentTypePart
(
0
,
"sharedStrings"
)
rels
:=
f
.
relsReader
(
"xl/_rels/workbook.xml.rels"
)
for
_
,
rel
:=
range
rels
.
Relationships
{
...
...
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