Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xuri
excelize
提交
2285d4dc
excelize
项目概览
xuri
/
excelize
通知
13
Star
2
Fork
4
代码
文件
提交
分支
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,体验更适合开发者的 AI 搜索 >>
已验证
提交
2285d4dc
编写于
4月 24, 2020
作者:
xurime
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
handle the cell without r attribute in a row element
上级
1fe660df
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
5 deletion
+33
-5
rows.go
rows.go
+16
-0
rows_test.go
rows_test.go
+11
-0
sheet.go
sheet.go
+5
-5
xmlDrawing.go
xmlDrawing.go
+1
-0
未找到文件。
rows.go
浏览文件 @
2285d4dc
...
...
@@ -593,6 +593,22 @@ func checkRow(xlsx *xlsxWorksheet) error {
if
colCount
==
0
{
continue
}
// check and fill the cell without r attribute in a row element
rCount
:=
0
for
idx
,
cell
:=
range
rowData
.
C
{
rCount
++
if
cell
.
R
!=
""
{
lastR
,
_
,
err
:=
CellNameToCoordinates
(
cell
.
R
)
if
err
!=
nil
{
return
err
}
if
lastR
>
rCount
{
rCount
=
lastR
}
continue
}
rowData
.
C
[
idx
]
.
R
,
_
=
CoordinatesToCellName
(
rCount
,
rowIdx
+
1
)
}
lastCol
,
_
,
err
:=
CellNameToCoordinates
(
rowData
.
C
[
colCount
-
1
]
.
R
)
if
err
!=
nil
{
return
err
...
...
rows_test.go
浏览文件 @
2285d4dc
...
...
@@ -831,6 +831,17 @@ func TestErrSheetNotExistError(t *testing.T) {
assert
.
EqualValues
(
t
,
err
.
Error
(),
"sheet Sheet1 is not exist"
)
}
func
TestCheckRow
(
t
*
testing
.
T
)
{
f
:=
NewFile
()
f
.
XLSX
[
"xl/worksheets/sheet1.xml"
]
=
[]
byte
(
`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" ><sheetData><row r="2"><c><v>1</v></c><c r="F2"><v>2</v></c><c><v>3</v></c><c><v>4</v></c><c r="M2"><v>5</v></c></row></sheetData></worksheet>`
)
_
,
err
:=
f
.
GetRows
(
"Sheet1"
)
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
f
.
SetCellValue
(
"Sheet1"
,
"A1"
,
false
))
f
=
NewFile
()
f
.
XLSX
[
"xl/worksheets/sheet1.xml"
]
=
[]
byte
(
`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" ><sheetData><row r="2"><c><v>1</v></c><c r="-"><v>2</v></c><c><v>3</v></c><c><v>4</v></c><c r="M2"><v>5</v></c></row></sheetData></worksheet>`
)
assert
.
EqualError
(
t
,
f
.
SetCellValue
(
"Sheet1"
,
"A1"
,
false
),
`cannot convert cell "-" to coordinates: invalid cell name "-"`
)
}
func
BenchmarkRows
(
b
*
testing
.
B
)
{
f
,
_
:=
OpenFile
(
filepath
.
Join
(
"test"
,
"Book1.xlsx"
))
for
i
:=
0
;
i
<
b
.
N
;
i
++
{
...
...
sheet.go
浏览文件 @
2285d4dc
...
...
@@ -237,7 +237,7 @@ func (f *File) SetActiveSheet(index int) {
for
idx
,
name
:=
range
f
.
GetSheetList
()
{
xlsx
,
err
:=
f
.
workSheetReader
(
name
)
if
err
!=
nil
{
// Chartsheet
// Chartsheet
or dialogsheet
return
}
if
xlsx
.
SheetViews
==
nil
{
...
...
@@ -365,8 +365,8 @@ func (f *File) GetSheetIndex(name string) int {
return
idx
}
// GetSheetMap provides a function to get worksheet
and chartsheet name
and
//
ID
map of XLSX. For example:
// GetSheetMap provides a function to get worksheet
, chartsheet
and
//
dialogsheet ID and name
map of XLSX. For example:
//
// f, err := excelize.OpenFile("Book1.xlsx")
// if err != nil {
...
...
@@ -387,8 +387,8 @@ func (f *File) GetSheetMap() map[int]string {
return
sheetMap
}
// GetSheetList provides a function to get worksheet
and chartsheet name list
// of workbook.
// GetSheetList provides a function to get worksheet
, chartsheet and
//
dialogsheet name list
of workbook.
func
(
f
*
File
)
GetSheetList
()
(
list
[]
string
)
{
wb
:=
f
.
workbookReader
()
if
wb
!=
nil
{
...
...
xmlDrawing.go
浏览文件 @
2285d4dc
...
...
@@ -23,6 +23,7 @@ const (
SourceRelationshipHyperLink
=
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"
SourceRelationshipWorkSheet
=
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"
SourceRelationshipChartsheet
=
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet"
SourceRelationshipDialogsheet
=
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/dialogsheet"
SourceRelationshipPivotTable
=
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable"
SourceRelationshipPivotCache
=
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition"
SourceRelationshipSharedStrings
=
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录