Skip to content

Commit

Permalink
- Support set custom number format, relate issue qax-os#86;
Browse files Browse the repository at this point in the history
- go test and godoc updated
  • Loading branch information
xuri committed Jul 27, 2017
1 parent 8493fea commit 4a74951
Show file tree
Hide file tree
Showing 3 changed files with 301 additions and 254 deletions.
24 changes: 22 additions & 2 deletions excelize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,8 @@ func TestSetCellStyleCurrencyNumberFormat(t *testing.T) {
if err != nil {
t.Log(err)
}
xlsx.SetCellValue("Sheet1", "A1", 37947.7500001)
xlsx.SetCellValue("Sheet1", "A2", 37947.7500001)
xlsx.SetCellValue("Sheet1", "A1", 42920.5)
xlsx.SetCellValue("Sheet1", "A2", 42920.5)

style, err = xlsx.NewStyle(`{"number_format": 26, "lang": "zh-tw"}`)
if err != nil {
Expand Down Expand Up @@ -450,6 +450,26 @@ func TestSetCellStyleCurrencyNumberFormat(t *testing.T) {
}
}

func TestSetCellStyleCustomNumberFormat(t *testing.T) {
xlsx := NewFile()
xlsx.SetCellValue("Sheet1", "A1", 42920.5)
xlsx.SetCellValue("Sheet1", "A2", 42920.5)
style, err := xlsx.NewStyle(`{"custom_number_format": "[$-380A]dddd\\,\\ dd\" de \"mmmm\" de \"yyyy;@"}`)
if err != nil {
t.Log(err)
}
xlsx.SetCellStyle("Sheet1", "A1", "A1", style)
style, err = xlsx.NewStyle(`{"custom_number_format": "[$-380A]dddd\\,\\ dd\" de \"mmmm\" de \"yyyy;@"}`)
if err != nil {
t.Log(err)
}
xlsx.SetCellStyle("Sheet1", "A2", "A2", style)
err = xlsx.SaveAs("./test/Workbook_custom_number_format.xlsx")
if err != nil {
t.Log(err)
}
}

func TestSetCellStyleFill(t *testing.T) {
xlsx, err := OpenFile("./test/Workbook_2.xlsx")
if err != nil {
Expand Down
Loading

0 comments on commit 4a74951

Please sign in to comment.