Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wx5575
excelize
提交
9e64df6a
excelize
项目概览
wx5575
/
excelize
与 Fork 源项目一致
Fork自
xuri / excelize
通知
1
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,体验更适合开发者的 AI 搜索 >>
已验证
提交
9e64df6a
编写于
1月 05, 2022
作者:
xurime
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update create style example, using a pointer of the structure instead of JSON
上级
e37e060d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
57 addition
and
12 deletion
+57
-12
calc_test.go
calc_test.go
+0
-1
cell.go
cell.go
+10
-2
stream.go
stream.go
+1
-1
stream_test.go
stream_test.go
+1
-1
styles.go
styles.go
+45
-7
未找到文件。
calc_test.go
浏览文件 @
9e64df6a
...
...
@@ -3285,7 +3285,6 @@ func TestCalcCellValue(t *testing.T) {
"=YIELD(
\"
01/01/2010
\"
,
\"
06/30/2015
\"
,-1,101,100,4)"
:
"PRICE requires rate >= 0"
,
"=YIELD(
\"
01/01/2010
\"
,
\"
06/30/2015
\"
,10%,0,100,4)"
:
"PRICE requires pr > 0"
,
"=YIELD(
\"
01/01/2010
\"
,
\"
06/30/2015
\"
,10%,101,-1,4)"
:
"PRICE requires redemption >= 0"
,
// "=YIELD(\"01/01/2010\",\"06/30/2015\",10%,101,100,4)": "PRICE requires rate >= 0",
// YIELDDISC
"=YIELDDISC()"
:
"YIELDDISC requires 4 or 5 arguments"
,
"=YIELDDISC(
\"\"
,
\"
06/30/2017
\"
,97,100,0)"
:
"#VALUE!"
,
...
...
cell.go
浏览文件 @
9e64df6a
...
...
@@ -666,9 +666,17 @@ type HyperlinkOpts struct {
// in this workbook. Maximum limit hyperlinks in a worksheet is 65530. The
// below is example for external link.
//
// err := f.SetCellHyperLink("Sheet1", "A3", "https://github.com/xuri/excelize", "External")
// if err := f.SetCellHyperLink("Sheet1", "A3",
// "https://github.com/xuri/excelize", "External"); err != nil {
// fmt.Println(err)
// }
// // Set underline and font color style for the cell.
// style, err := f.NewStyle(`{"font":{"color":"#1265BE","underline":"single"}}`)
// style, err := f.NewStyle(&excelize.Style{
// Font: &excelize.Font{Color: "#1265BE", Underline: "single"},
// })
// if err != nil {
// fmt.Println(err)
// }
// err = f.SetCellStyle("Sheet1", "A3", "A3", style)
//
// A this is another example for "Location":
...
...
stream.go
浏览文件 @
9e64df6a
...
...
@@ -52,7 +52,7 @@ type StreamWriter struct {
// if err != nil {
// fmt.Println(err)
// }
// styleID, err := file.NewStyle(
`{"font":{"color":"#777777"}}`
)
// styleID, err := file.NewStyle(
&excelize.Style{Font: &excelize.Font{Color: "#777777"}}
)
// if err != nil {
// fmt.Println(err)
// }
...
...
stream_test.go
浏览文件 @
9e64df6a
...
...
@@ -53,7 +53,7 @@ func TestStreamWriter(t *testing.T) {
assert
.
NoError
(
t
,
streamWriter
.
SetRow
(
"A3"
,
row
))
// Test set cell with style.
styleID
,
err
:=
file
.
NewStyle
(
`{"font":{"color":"#777777"}}`
)
styleID
,
err
:=
file
.
NewStyle
(
&
Style
{
Font
:
&
Font
{
Color
:
"#777777"
}}
)
assert
.
NoError
(
t
,
err
)
assert
.
NoError
(
t
,
streamWriter
.
SetRow
(
"A4"
,
[]
interface
{}{
Cell
{
StyleID
:
styleID
},
Cell
{
Formula
:
"SUM(A10,B10)"
}}),
RowOpts
{
Height
:
45
,
StyleID
:
styleID
})
assert
.
NoError
(
t
,
streamWriter
.
SetRow
(
"A5"
,
[]
interface
{}{
&
Cell
{
StyleID
:
styleID
,
Value
:
"cell"
},
&
Cell
{
Formula
:
"SUM(A10,B10)"
}}))
...
...
styles.go
浏览文件 @
9e64df6a
...
...
@@ -2628,7 +2628,16 @@ func (f *File) GetCellStyle(sheet, axis string) (int, error) {
//
// For example create a borders of cell H9 on Sheet1:
//
// style, err := f.NewStyle(`{"border":[{"type":"left","color":"0000FF","style":3},{"type":"top","color":"00FF00","style":4},{"type":"bottom","color":"FFFF00","style":5},{"type":"right","color":"FF0000","style":6},{"type":"diagonalDown","color":"A020F0","style":7},{"type":"diagonalUp","color":"A020F0","style":8}]}`)
// style, err := f.NewStyle(&excelize.Style{
// Border: []excelize.Border{
// {Type: "left", Color: "0000FF", Style: 3},
// {Type: "top", Color: "00FF00", Style: 4},
// {Type: "bottom", Color: "FFFF00", Style: 5},
// {Type: "right", Color: "FF0000", Style: 6},
// {Type: "diagonalDown", Color: "A020F0", Style: 7},
// {Type: "diagonalUp", Color: "A020F0", Style: 8},
// },
// })
// if err != nil {
// fmt.Println(err)
// }
...
...
@@ -2637,7 +2646,9 @@ func (f *File) GetCellStyle(sheet, axis string) (int, error) {
// Set gradient fill with vertical variants shading styles for cell H9 on
// Sheet1:
//
// style, err := f.NewStyle(`{"fill":{"type":"gradient","color":["#FFFFFF","#E0EBF5"],"shading":1}}`)
// style, err := f.NewStyle(&excelize.Style{
// Fill: excelize.Fill{Type: "gradient", Color: []string{"#FFFFFF", "#E0EBF5"}, Shading: 1},
// })
// if err != nil {
// fmt.Println(err)
// }
...
...
@@ -2645,7 +2656,9 @@ func (f *File) GetCellStyle(sheet, axis string) (int, error) {
//
// Set solid style pattern fill for cell H9 on Sheet1:
//
// style, err := f.NewStyle(`{"fill":{"type":"pattern","color":["#E0EBF5"],"pattern":1}}`)
// style, err := f.NewStyle(&excelize.Style{
// Fill: excelize.Fill{Type: "pattern", Color: []string{"#E0EBF5"}, Pattern: 1},
// })
// if err != nil {
// fmt.Println(err)
// }
...
...
@@ -2653,7 +2666,19 @@ func (f *File) GetCellStyle(sheet, axis string) (int, error) {
//
// Set alignment style for cell H9 on Sheet1:
//
// style, err := f.NewStyle(`{"alignment":{"horizontal":"center","ident":1,"justify_last_line":true,"reading_order":0,"relative_indent":1,"shrink_to_fit":true,"text_rotation":45,"vertical":"","wrap_text":true}}`)
// style, err := f.NewStyle(&excelize.Style{
// Alignment: &excelize.Alignment{
// Horizontal: "center",
// Indent: 1,
// JustifyLastLine: true,
// ReadingOrder: 0,
// RelativeIndent: 1,
// ShrinkToFit: true,
// TextRotation: 45,
// Vertical: "",
// WrapText: true,
// },
// })
// if err != nil {
// fmt.Println(err)
// }
...
...
@@ -2664,7 +2689,7 @@ func (f *File) GetCellStyle(sheet, axis string) (int, error) {
// for cell H9 on Sheet1:
//
// f.SetCellValue("Sheet1", "H9", 42920.5)
// style, err := f.NewStyle(
`{"number_format": 22}`
)
// style, err := f.NewStyle(
&excelize.Style{NumFmt: 22}
)
// if err != nil {
// fmt.Println(err)
// }
...
...
@@ -2672,7 +2697,15 @@ func (f *File) GetCellStyle(sheet, axis string) (int, error) {
//
// Set font style for cell H9 on Sheet1:
//
// style, err := f.NewStyle(`{"font":{"bold":true,"italic":true,"family":"Times New Roman","size":36,"color":"#777777"}}`)
// style, err := f.NewStyle(&excelize.Style{
// Font: &excelize.Font{
// Bold: true,
// Italic: true,
// Family: "Times New Roman",
// Size: 36,
// Color: "#777777",
// },
// })
// if err != nil {
// fmt.Println(err)
// }
...
...
@@ -2680,7 +2713,12 @@ func (f *File) GetCellStyle(sheet, axis string) (int, error) {
//
// Hide and lock for cell H9 on Sheet1:
//
// style, err := f.NewStyle(`{"protection":{"hidden":true, "locked":true}}`)
// style, err := f.NewStyle(&excelize.Style{
// Protection: &excelize.Protection{
// Hidden: true,
// Locked: true,
// },
// })
// if err != nil {
// fmt.Println(err)
// }
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录