Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xuri
excelize
提交
f91f5486
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 搜索 >>
已验证
提交
f91f5486
编写于
5月 17, 2019
作者:
xurime
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Resolve #404, get sheet map by target rels.
上级
7e77e148
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
20 addition
and
23 deletion
+20
-23
sheet.go
sheet.go
+11
-5
styles.go
styles.go
+3
-6
xmlStyles.go
xmlStyles.go
+4
-9
xmlWorkbook.go
xmlWorkbook.go
+2
-3
未找到文件。
sheet.go
浏览文件 @
f91f5486
...
...
@@ -369,12 +369,18 @@ func (f *File) GetSheetMap() map[int]string {
return
sheetMap
}
// getSheetMap provides a function to get worksheet name and XML file path map
of
// XLSX.
// getSheetMap provides a function to get worksheet name and XML file path map
//
of
XLSX.
func
(
f
*
File
)
getSheetMap
()
map
[
string
]
string
{
maps
:=
make
(
map
[
string
]
string
)
for
idx
,
name
:=
range
f
.
GetSheetMap
()
{
maps
[
name
]
=
"xl/worksheets/sheet"
+
strconv
.
Itoa
(
idx
)
+
".xml"
content
:=
f
.
workbookReader
()
rels
:=
f
.
workbookRelsReader
()
maps
:=
map
[
string
]
string
{}
for
_
,
v
:=
range
content
.
Sheets
.
Sheet
{
for
_
,
rel
:=
range
rels
.
Relationships
{
if
rel
.
ID
==
v
.
ID
{
maps
[
v
.
Name
]
=
fmt
.
Sprintf
(
"xl/%s"
,
rel
.
Target
)
}
}
}
return
maps
}
...
...
styles.go
浏览文件 @
f91f5486
...
...
@@ -1895,11 +1895,8 @@ func (f *File) NewStyle(style string) (int, error) {
numFmtID
:=
setNumFmt
(
s
,
fs
)
if
fs
.
Font
!=
nil
{
font
,
_
:=
xml
.
Marshal
(
setFont
(
fs
))
s
.
Fonts
.
Count
++
s
.
Fonts
.
Font
=
append
(
s
.
Fonts
.
Font
,
&
xlsxFont
{
Font
:
string
(
font
[
6
:
len
(
font
)
-
7
]),
})
s
.
Fonts
.
Font
=
append
(
s
.
Fonts
.
Font
,
setFont
(
fs
))
fontID
=
s
.
Fonts
.
Count
-
1
}
...
...
@@ -1950,7 +1947,7 @@ func (f *File) NewConditionalStyle(style string) (int, error) {
// setFont provides a function to add font style by given cell format
// settings.
func
setFont
(
formatStyle
*
formatStyle
)
*
f
ont
{
func
setFont
(
formatStyle
*
formatStyle
)
*
xlsxF
ont
{
fontUnderlineType
:=
map
[
string
]
string
{
"single"
:
"single"
,
"double"
:
"double"
}
if
formatStyle
.
Font
.
Size
<
1
{
formatStyle
.
Font
.
Size
=
11
...
...
@@ -1958,7 +1955,7 @@ func setFont(formatStyle *formatStyle) *font {
if
formatStyle
.
Font
.
Color
==
""
{
formatStyle
.
Font
.
Color
=
"#000000"
}
f
:=
f
ont
{
f
:=
xlsxF
ont
{
B
:
formatStyle
.
Font
.
Bold
,
I
:
formatStyle
.
Font
.
Italic
,
Sz
:
&
attrValInt
{
Val
:
formatStyle
.
Font
.
Size
},
...
...
xmlStyles.go
浏览文件 @
f91f5486
...
...
@@ -82,8 +82,9 @@ type xlsxFonts struct {
Font
[]
*
xlsxFont
`xml:"font"`
}
// font directly maps the font element.
type
font
struct
{
// xlsxFont directly maps the font element. This element defines the
// properties for one of the fonts used in this workbook.
type
xlsxFont
struct
{
Name
*
attrValString
`xml:"name"`
Charset
*
attrValInt
`xml:"charset"`
Family
*
attrValInt
`xml:"family"`
...
...
@@ -100,12 +101,6 @@ type font struct {
Scheme
*
attrValString
`xml:"scheme"`
}
// xlsxFont directly maps the font element. This element defines the properties
// for one of the fonts used in this workbook.
type
xlsxFont
struct
{
Font
string
`xml:",innerxml"`
}
// xlsxFills directly maps the fills element. This element defines the cell
// fills portion of the Styles part, consisting of a sequence of fill records. A
// cell fill consists of a background color, foreground color, and pattern to be
...
...
@@ -262,7 +257,7 @@ type xlsxDxf struct {
// dxf directly maps the dxf element.
type
dxf
struct
{
Font
*
font
`xml:"font"`
Font
*
xlsxFont
`xml:"font"`
NumFmt
*
xlsxNumFmt
`xml:"numFmt"`
Fill
*
xlsxFill
`xml:"fill"`
Alignment
*
xlsxAlignment
`xml:"alignment"`
...
...
xmlWorkbook.go
浏览文件 @
f91f5486
...
...
@@ -146,9 +146,8 @@ type xlsxSheets struct {
Sheet
[]
xlsxSheet
`xml:"sheet"`
}
// xlsxSheet directly maps the sheet element from the namespace
// http://schemas.openxmlformats.org/spreadsheetml/2006/main - currently I have
// not checked it for completeness - it does as much as I need.
// xlsxSheet defines a sheet in this workbook. Sheet data is stored in a
// separate part.
type
xlsxSheet
struct
{
Name
string
`xml:"name,attr,omitempty"`
SheetID
int
`xml:"sheetId,attr,omitempty"`
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录