Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xuri
excelize
提交
18aa606f
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 搜索 >>
未验证
提交
18aa606f
编写于
5月 09, 2018
作者:
xurime
提交者:
GitHub
5月 09, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #221 from srdolor/outline
Added functions to set and get outline level for columns and rows.
上级
e8961f0a
e70618d0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
80 addition
and
0 deletion
+80
-0
col.go
col.go
+53
-0
rows.go
rows.go
+27
-0
未找到文件。
col.go
浏览文件 @
18aa606f
...
...
@@ -67,6 +67,59 @@ func (f *File) SetColVisible(sheet, column string, visible bool) {
xlsx
.
Cols
.
Col
=
append
(
xlsx
.
Cols
.
Col
,
col
)
}
// GetColOutlineLevel provides a function to get outline level of a single column by given
// worksheet name and column name. For example, get outline level of column D
// in Sheet1:
//
// xlsx.getColOutlineLevel("Sheet1", "D")
//
func
(
f
*
File
)
GetColOutlineLevel
(
sheet
,
column
string
)
uint8
{
xlsx
:=
f
.
workSheetReader
(
sheet
)
col
:=
TitleToNumber
(
strings
.
ToUpper
(
column
))
+
1
level
:=
uint8
(
0
)
if
xlsx
.
Cols
==
nil
{
return
level
}
for
c
:=
range
xlsx
.
Cols
.
Col
{
if
xlsx
.
Cols
.
Col
[
c
]
.
Min
<=
col
&&
col
<=
xlsx
.
Cols
.
Col
[
c
]
.
Max
{
level
=
xlsx
.
Cols
.
Col
[
c
]
.
OutlineLevel
}
}
return
level
}
// SetColOutlineLevel provides a function to set outline level of a single column by given
// worksheet name and column name. For example, set outline level of column D in Sheet1 to 2:
//
// xlsx.SetColOutlineLevel("Sheet1", "D", 2)
//
func
(
f
*
File
)
SetColOutlineLevel
(
sheet
,
column
string
,
level
uint8
)
{
xlsx
:=
f
.
workSheetReader
(
sheet
)
c
:=
TitleToNumber
(
strings
.
ToUpper
(
column
))
+
1
col
:=
xlsxCol
{
Min
:
c
,
Max
:
c
,
OutlineLevel
:
level
,
CustomWidth
:
true
,
}
if
xlsx
.
Cols
==
nil
{
cols
:=
xlsxCols
{}
cols
.
Col
=
append
(
cols
.
Col
,
col
)
xlsx
.
Cols
=
&
cols
return
}
for
v
:=
range
xlsx
.
Cols
.
Col
{
if
xlsx
.
Cols
.
Col
[
v
]
.
Min
<=
c
&&
c
<=
xlsx
.
Cols
.
Col
[
v
]
.
Max
{
col
=
xlsx
.
Cols
.
Col
[
v
]
}
}
col
.
Min
=
c
col
.
Max
=
c
col
.
OutlineLevel
=
level
col
.
CustomWidth
=
true
xlsx
.
Cols
.
Col
=
append
(
xlsx
.
Cols
.
Col
,
col
)
}
// SetColWidth provides function to set the width of a single column or multiple
// columns. For example:
//
...
...
rows.go
浏览文件 @
18aa606f
...
...
@@ -301,6 +301,33 @@ func (f *File) GetRowVisible(sheet string, rowIndex int) bool {
return
!
xlsx
.
SheetData
.
Row
[
rowIndex
]
.
Hidden
}
// SetRowOutlineLevel provides a function to set outline level number of a single row by given
// worksheet name and row index. For example, outline row 2 in Sheet1 to level 1:
//
// xlsx.SetRowOutlineLevel("Sheet1", 2, 1)
//
func
(
f
*
File
)
SetRowOutlineLevel
(
sheet
string
,
rowIndex
int
,
level
uint8
)
{
xlsx
:=
f
.
workSheetReader
(
sheet
)
rows
:=
rowIndex
+
1
cells
:=
0
completeRow
(
xlsx
,
rows
,
cells
)
xlsx
.
SheetData
.
Row
[
rowIndex
]
.
OutlineLevel
=
level
}
// GetRowOutlineLevel provides a function to get outline level number of a single row by given
// worksheet name and row index. For example, get outline number of row 2 in
// Sheet1:
//
// xlsx.GetRowOutlineLevel("Sheet1", 2)
//
func
(
f
*
File
)
GetRowOutlineLevel
(
sheet
string
,
rowIndex
int
)
uint8
{
xlsx
:=
f
.
workSheetReader
(
sheet
)
rows
:=
rowIndex
+
1
cells
:=
0
completeRow
(
xlsx
,
rows
,
cells
)
return
xlsx
.
SheetData
.
Row
[
rowIndex
]
.
OutlineLevel
}
// RemoveRow provides function to remove single row by given worksheet name and
// row index. For example, remove row 3 in Sheet1:
//
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录