Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
此号慢热型
excelize
提交
9b5b74d4
excelize
项目概览
此号慢热型
/
excelize
与 Fork 源项目一致
Fork自
xuri / excelize
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
excelize
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
已验证
提交
9b5b74d4
编写于
10月 16, 2017
作者:
xurime
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Performance optimization, use the array index instead of the value in range.
上级
905be463
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
44 addition
and
44 deletion
+44
-44
cell.go
cell.go
+16
-16
chart.go
chart.go
+6
-6
col.go
col.go
+14
-14
excelize.go
excelize.go
+4
-4
rows.go
rows.go
+4
-4
未找到文件。
cell.go
浏览文件 @
9b5b74d4
...
@@ -91,11 +91,11 @@ func (f *File) GetCellValue(sheet, axis string) string {
...
@@ -91,11 +91,11 @@ func (f *File) GetCellValue(sheet, axis string) string {
if
rows
<
xAxis
{
if
rows
<
xAxis
{
return
""
return
""
}
}
for
_
,
v
:=
range
xlsx
.
SheetData
.
Row
{
for
k
:=
range
xlsx
.
SheetData
.
Row
{
if
v
.
R
==
row
{
if
xlsx
.
SheetData
.
Row
[
k
]
.
R
==
row
{
for
_
,
r
:=
range
v
.
C
{
for
i
:=
range
xlsx
.
SheetData
.
Row
[
k
]
.
C
{
if
axis
==
r
.
R
{
if
axis
==
xlsx
.
SheetData
.
Row
[
k
]
.
C
[
i
]
.
R
{
val
,
_
:=
r
.
getValueFrom
(
f
,
f
.
sharedStringsReader
())
val
,
_
:=
xlsx
.
SheetData
.
Row
[
k
]
.
C
[
i
]
.
getValueFrom
(
f
,
f
.
sharedStringsReader
())
return
val
return
val
}
}
}
}
...
@@ -161,12 +161,12 @@ func (f *File) GetCellFormula(sheet, axis string) string {
...
@@ -161,12 +161,12 @@ func (f *File) GetCellFormula(sheet, axis string) string {
if
rows
<
xAxis
{
if
rows
<
xAxis
{
return
""
return
""
}
}
for
_
,
v
:=
range
xlsx
.
SheetData
.
Row
{
for
k
:=
range
xlsx
.
SheetData
.
Row
{
if
v
.
R
==
row
{
if
xlsx
.
SheetData
.
Row
[
k
]
.
R
==
row
{
for
_
,
f
:=
range
v
.
C
{
for
i
:=
range
xlsx
.
SheetData
.
Row
[
k
]
.
C
{
if
axis
==
f
.
R
{
if
axis
==
xlsx
.
SheetData
.
Row
[
k
]
.
C
[
i
]
.
R
{
if
f
.
F
!=
nil
{
if
xlsx
.
SheetData
.
Row
[
k
]
.
C
[
i
]
.
F
!=
nil
{
return
f
.
F
.
Content
return
xlsx
.
SheetData
.
Row
[
k
]
.
C
[
i
]
.
F
.
Content
}
}
}
}
}
}
...
@@ -256,12 +256,12 @@ func (f *File) GetCellHyperLink(sheet, axis string) (bool, string) {
...
@@ -256,12 +256,12 @@ func (f *File) GetCellHyperLink(sheet, axis string) (bool, string) {
if
xlsx
.
Hyperlinks
==
nil
||
axis
==
""
{
if
xlsx
.
Hyperlinks
==
nil
||
axis
==
""
{
return
link
,
target
return
link
,
target
}
}
for
_
,
h
:=
range
xlsx
.
Hyperlinks
.
Hyperlink
{
for
h
:=
range
xlsx
.
Hyperlinks
.
Hyperlink
{
if
h
.
Ref
==
axis
{
if
xlsx
.
Hyperlinks
.
Hyperlink
[
h
]
.
Ref
==
axis
{
link
=
true
link
=
true
target
=
h
.
Location
target
=
xlsx
.
Hyperlinks
.
Hyperlink
[
h
]
.
Location
if
h
.
RID
!=
""
{
if
xlsx
.
Hyperlinks
.
Hyperlink
[
h
]
.
RID
!=
""
{
target
=
f
.
getSheetRelationshipsTargetByID
(
sheet
,
h
.
RID
)
target
=
f
.
getSheetRelationshipsTargetByID
(
sheet
,
xlsx
.
Hyperlinks
.
Hyperlink
[
h
]
.
RID
)
}
}
}
}
}
}
...
...
chart.go
浏览文件 @
9b5b74d4
...
@@ -550,23 +550,23 @@ func (f *File) drawScatterChart(formatSet *formatChart) *cPlotArea {
...
@@ -550,23 +550,23 @@ func (f *File) drawScatterChart(formatSet *formatChart) *cPlotArea {
// sets.
// sets.
func
(
f
*
File
)
drawChartSeries
(
formatSet
*
formatChart
)
*
[]
cSer
{
func
(
f
*
File
)
drawChartSeries
(
formatSet
*
formatChart
)
*
[]
cSer
{
ser
:=
[]
cSer
{}
ser
:=
[]
cSer
{}
for
k
,
v
:=
range
formatSet
.
Series
{
for
k
:=
range
formatSet
.
Series
{
ser
=
append
(
ser
,
cSer
{
ser
=
append
(
ser
,
cSer
{
IDx
:
&
attrValInt
{
Val
:
k
},
IDx
:
&
attrValInt
{
Val
:
k
},
Order
:
&
attrValInt
{
Val
:
k
},
Order
:
&
attrValInt
{
Val
:
k
},
Tx
:
&
cTx
{
Tx
:
&
cTx
{
StrRef
:
&
cStrRef
{
StrRef
:
&
cStrRef
{
F
:
v
.
Name
,
F
:
formatSet
.
Series
[
k
]
.
Name
,
},
},
},
},
SpPr
:
f
.
drawChartSeriesSpPr
(
k
,
formatSet
),
SpPr
:
f
.
drawChartSeriesSpPr
(
k
,
formatSet
),
Marker
:
f
.
drawChartSeriesMarker
(
k
,
formatSet
),
Marker
:
f
.
drawChartSeriesMarker
(
k
,
formatSet
),
DPt
:
f
.
drawChartSeriesDPt
(
k
,
formatSet
),
DPt
:
f
.
drawChartSeriesDPt
(
k
,
formatSet
),
DLbls
:
f
.
drawChartSeriesDLbls
(
formatSet
),
DLbls
:
f
.
drawChartSeriesDLbls
(
formatSet
),
Cat
:
f
.
drawChartSeriesCat
(
v
,
formatSet
),
Cat
:
f
.
drawChartSeriesCat
(
formatSet
.
Series
[
k
]
,
formatSet
),
Val
:
f
.
drawChartSeriesVal
(
v
,
formatSet
),
Val
:
f
.
drawChartSeriesVal
(
formatSet
.
Series
[
k
]
,
formatSet
),
XVal
:
f
.
drawChartSeriesXVal
(
v
,
formatSet
),
XVal
:
f
.
drawChartSeriesXVal
(
formatSet
.
Series
[
k
]
,
formatSet
),
YVal
:
f
.
drawChartSeriesYVal
(
v
,
formatSet
),
YVal
:
f
.
drawChartSeriesYVal
(
formatSet
.
Series
[
k
]
,
formatSet
),
})
})
}
}
return
&
ser
return
&
ser
...
...
col.go
浏览文件 @
9b5b74d4
...
@@ -27,9 +27,9 @@ func (f *File) GetColVisible(sheet, column string) bool {
...
@@ -27,9 +27,9 @@ func (f *File) GetColVisible(sheet, column string) bool {
if
xlsx
.
Cols
==
nil
{
if
xlsx
.
Cols
==
nil
{
return
visible
return
visible
}
}
for
_
,
c
:=
range
xlsx
.
Cols
.
Col
{
for
c
:=
range
xlsx
.
Cols
.
Col
{
if
c
.
Min
<=
col
&&
col
<=
c
.
Max
{
if
xlsx
.
Cols
.
Col
[
c
]
.
Min
<=
col
&&
col
<=
xlsx
.
Cols
.
Col
[
c
]
.
Max
{
visible
=
!
c
.
Hidden
visible
=
!
xlsx
.
Cols
.
Col
[
c
]
.
Hidden
}
}
}
}
return
visible
return
visible
...
@@ -55,9 +55,9 @@ func (f *File) SetColVisible(sheet, column string, visible bool) {
...
@@ -55,9 +55,9 @@ func (f *File) SetColVisible(sheet, column string, visible bool) {
xlsx
.
Cols
=
&
cols
xlsx
.
Cols
=
&
cols
return
return
}
}
for
_
,
v
:=
range
xlsx
.
Cols
.
Col
{
for
v
:=
range
xlsx
.
Cols
.
Col
{
if
v
.
Min
<=
c
&&
c
<=
v
.
Max
{
if
xlsx
.
Cols
.
Col
[
v
]
.
Min
<=
c
&&
c
<=
xlsx
.
Cols
.
Col
[
v
]
.
Max
{
col
=
v
col
=
xlsx
.
Cols
.
Col
[
v
]
}
}
}
}
col
.
Min
=
c
col
.
Min
=
c
...
@@ -262,12 +262,12 @@ func (f *File) InsertCol(sheet, column string) {
...
@@ -262,12 +262,12 @@ func (f *File) InsertCol(sheet, column string) {
//
//
func
(
f
*
File
)
RemoveCol
(
sheet
,
column
string
)
{
func
(
f
*
File
)
RemoveCol
(
sheet
,
column
string
)
{
xlsx
:=
f
.
workSheetReader
(
sheet
)
xlsx
:=
f
.
workSheetReader
(
sheet
)
for
i
,
r
:=
range
xlsx
.
SheetData
.
Row
{
for
r
:=
range
xlsx
.
SheetData
.
Row
{
for
k
,
v
:=
range
r
.
C
{
for
k
,
v
:=
range
xlsx
.
SheetData
.
Row
[
r
]
.
C
{
axis
:=
v
.
R
axis
:=
v
.
R
col
:=
string
(
strings
.
Map
(
letterOnlyMapF
,
axis
))
col
:=
string
(
strings
.
Map
(
letterOnlyMapF
,
axis
))
if
col
==
column
{
if
col
==
column
{
xlsx
.
SheetData
.
Row
[
i
]
.
C
=
append
(
xlsx
.
SheetData
.
Row
[
i
]
.
C
[
:
k
],
xlsx
.
SheetData
.
Row
[
i
]
.
C
[
k
+
1
:
]
...
)
xlsx
.
SheetData
.
Row
[
r
]
.
C
=
append
(
xlsx
.
SheetData
.
Row
[
r
]
.
C
[
:
k
],
xlsx
.
SheetData
.
Row
[
r
]
.
C
[
k
+
1
:
]
...
)
}
}
}
}
}
}
...
@@ -278,13 +278,13 @@ func (f *File) RemoveCol(sheet, column string) {
...
@@ -278,13 +278,13 @@ func (f *File) RemoveCol(sheet, column string) {
// Completion column element tags of XML in a sheet.
// Completion column element tags of XML in a sheet.
func
completeCol
(
xlsx
*
xlsxWorksheet
,
row
,
cell
int
)
{
func
completeCol
(
xlsx
*
xlsxWorksheet
,
row
,
cell
int
)
{
buffer
:=
bytes
.
Buffer
{}
buffer
:=
bytes
.
Buffer
{}
for
k
,
v
:=
range
xlsx
.
SheetData
.
Row
{
for
r
:=
range
xlsx
.
SheetData
.
Row
{
if
len
(
v
.
C
)
<
cell
{
if
len
(
xlsx
.
SheetData
.
Row
[
r
]
.
C
)
<
cell
{
start
:=
len
(
v
.
C
)
start
:=
len
(
xlsx
.
SheetData
.
Row
[
r
]
.
C
)
for
iii
:=
start
;
iii
<
cell
;
iii
++
{
for
iii
:=
start
;
iii
<
cell
;
iii
++
{
buffer
.
WriteString
(
ToAlphaString
(
iii
))
buffer
.
WriteString
(
ToAlphaString
(
iii
))
buffer
.
WriteString
(
strconv
.
Itoa
(
k
+
1
))
buffer
.
WriteString
(
strconv
.
Itoa
(
r
+
1
))
xlsx
.
SheetData
.
Row
[
k
]
.
C
=
append
(
xlsx
.
SheetData
.
Row
[
k
]
.
C
,
xlsxC
{
xlsx
.
SheetData
.
Row
[
r
]
.
C
=
append
(
xlsx
.
SheetData
.
Row
[
r
]
.
C
,
xlsxC
{
R
:
buffer
.
String
(),
R
:
buffer
.
String
(),
})
})
buffer
.
Reset
()
buffer
.
Reset
()
...
...
excelize.go
浏览文件 @
9b5b74d4
...
@@ -113,8 +113,8 @@ func checkSheet(xlsx *xlsxWorksheet) {
...
@@ -113,8 +113,8 @@ func checkSheet(xlsx *xlsxWorksheet) {
}
}
sheetData
:=
xlsxSheetData
{}
sheetData
:=
xlsxSheetData
{}
existsRows
:=
map
[
int
]
int
{}
existsRows
:=
map
[
int
]
int
{}
for
k
,
v
:=
range
xlsx
.
SheetData
.
Row
{
for
k
:=
range
xlsx
.
SheetData
.
Row
{
existsRows
[
v
.
R
]
=
k
existsRows
[
xlsx
.
SheetData
.
Row
[
k
]
.
R
]
=
k
}
}
for
i
:=
0
;
i
<
row
;
i
++
{
for
i
:=
0
;
i
<
row
;
i
++
{
_
,
ok
:=
existsRows
[
i
+
1
]
_
,
ok
:=
existsRows
[
i
+
1
]
...
@@ -167,8 +167,8 @@ func replaceWorkSheetsRelationshipsNameSpace(workbookMarshal string) string {
...
@@ -167,8 +167,8 @@ func replaceWorkSheetsRelationshipsNameSpace(workbookMarshal string) string {
func
(
f
*
File
)
UpdateLinkedValue
()
{
func
(
f
*
File
)
UpdateLinkedValue
()
{
for
_
,
name
:=
range
f
.
GetSheetMap
()
{
for
_
,
name
:=
range
f
.
GetSheetMap
()
{
xlsx
:=
f
.
workSheetReader
(
name
)
xlsx
:=
f
.
workSheetReader
(
name
)
for
indexR
,
row
:=
range
xlsx
.
SheetData
.
Row
{
for
indexR
:=
range
xlsx
.
SheetData
.
Row
{
for
indexC
,
col
:=
range
row
.
C
{
for
indexC
,
col
:=
range
xlsx
.
SheetData
.
Row
[
indexR
]
.
C
{
if
col
.
F
!=
nil
&&
col
.
V
!=
""
{
if
col
.
F
!=
nil
&&
col
.
V
!=
""
{
xlsx
.
SheetData
.
Row
[
indexR
]
.
C
[
indexC
]
.
V
=
""
xlsx
.
SheetData
.
Row
[
indexR
]
.
C
[
indexC
]
.
V
=
""
xlsx
.
SheetData
.
Row
[
indexR
]
.
C
[
indexC
]
.
T
=
""
xlsx
.
SheetData
.
Row
[
indexR
]
.
C
[
indexC
]
.
T
=
""
...
...
rows.go
浏览文件 @
9b5b74d4
...
@@ -266,11 +266,11 @@ func (f *File) InsertRow(sheet string, row int) {
...
@@ -266,11 +266,11 @@ func (f *File) InsertRow(sheet string, row int) {
// 3000 rows one sheet).
// 3000 rows one sheet).
func
checkRow
(
xlsx
*
xlsxWorksheet
)
{
func
checkRow
(
xlsx
*
xlsxWorksheet
)
{
buffer
:=
bytes
.
Buffer
{}
buffer
:=
bytes
.
Buffer
{}
for
k
,
v
:=
range
xlsx
.
SheetData
.
Row
{
for
k
:=
range
xlsx
.
SheetData
.
Row
{
lenCol
:=
len
(
v
.
C
)
lenCol
:=
len
(
xlsx
.
SheetData
.
Row
[
k
]
.
C
)
if
lenCol
>
0
{
if
lenCol
>
0
{
endR
:=
string
(
strings
.
Map
(
letterOnlyMapF
,
v
.
C
[
lenCol
-
1
]
.
R
))
endR
:=
string
(
strings
.
Map
(
letterOnlyMapF
,
xlsx
.
SheetData
.
Row
[
k
]
.
C
[
lenCol
-
1
]
.
R
))
endRow
,
_
:=
strconv
.
Atoi
(
strings
.
Map
(
intOnlyMapF
,
v
.
C
[
lenCol
-
1
]
.
R
))
endRow
,
_
:=
strconv
.
Atoi
(
strings
.
Map
(
intOnlyMapF
,
xlsx
.
SheetData
.
Row
[
k
]
.
C
[
lenCol
-
1
]
.
R
))
endCol
:=
TitleToNumber
(
endR
)
+
1
endCol
:=
TitleToNumber
(
endR
)
+
1
if
lenCol
<
endCol
{
if
lenCol
<
endCol
{
oldRow
:=
xlsx
.
SheetData
.
Row
[
k
]
.
C
oldRow
:=
xlsx
.
SheetData
.
Row
[
k
]
.
C
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录