Skip to content

Commit bc31e54

Browse files
committed
- Currency format supported, relate issue qax-os#80;
- go test and godoc updated
1 parent 20aae4e commit bc31e54

File tree

4 files changed

+469
-135
lines changed

4 files changed

+469
-135
lines changed

chart.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,25 +89,16 @@ func parseFormatChartSet(formatSet string) *formatChart {
8989
//
9090
// The following shows the type of chart supported by excelize:
9191
//
92-
// +---------------------------+
9392
// | Type | Chart |
94-
// +==========+================+
95-
// | bar | bar chart |
9693
// +----------+----------------+
94+
// | bar | bar chart |
9795
// | bar3D | 3D bar chart |
98-
// +----------+----------------+
9996
// | doughnut | doughnut chart |
100-
// +----------+----------------+
10197
// | line | line chart |
102-
// +----------+----------------+
10398
// | pie | pie chart |
104-
// +----------+----------------+
10599
// | pie3D | 3D pie chart |
106-
// +----------+----------------+
107100
// | radar | radar chart |
108-
// +----------+----------------+
109101
// | scatter | scatter chart |
110-
// +----------+----------------+
111102
//
112103
// In Excel a chart series is a collection of information that defines which data is plotted such as values, axis labels and formatting.
113104
//

excelize_test.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,64 @@ func TestSetCellStyleNumberFormat(t *testing.T) {
392392
}
393393
}
394394

395+
func TestSetCellStyleCurrencyNumberFormat(t *testing.T) {
396+
xlsx, err := OpenFile("./test/Workbook_3.xlsx")
397+
if err != nil {
398+
t.Log(err)
399+
}
400+
xlsx.SetCellValue("Sheet1", "A1", 56)
401+
xlsx.SetCellValue("Sheet1", "A2", 32.3)
402+
var style int
403+
style, err = xlsx.NewStyle(`{"number_format": 188, "decimal_places": -1}`)
404+
if err != nil {
405+
t.Log(err)
406+
}
407+
xlsx.SetCellStyle("Sheet1", "A1", "A1", style)
408+
style, err = xlsx.NewStyle(`{"number_format": 188, "decimal_places": 31}`)
409+
if err != nil {
410+
t.Log(err)
411+
}
412+
xlsx.SetCellStyle("Sheet1", "A2", "A2", style)
413+
414+
err = xlsx.Save()
415+
if err != nil {
416+
t.Log(err)
417+
}
418+
419+
xlsx, err = OpenFile("./test/Workbook_4.xlsx")
420+
if err != nil {
421+
t.Log(err)
422+
}
423+
xlsx.SetCellValue("Sheet1", "A1", 37947.7500001)
424+
xlsx.SetCellValue("Sheet1", "A2", 37947.7500001)
425+
426+
style, err = xlsx.NewStyle(`{"number_format": 26, "lang": "zh-tw"}`)
427+
if err != nil {
428+
t.Log(err)
429+
}
430+
style, err = xlsx.NewStyle(`{"number_format": 27}`)
431+
if err != nil {
432+
t.Log(err)
433+
}
434+
xlsx.SetCellStyle("Sheet1", "A1", "A1", style)
435+
style, err = xlsx.NewStyle(`{"number_format": 31, "lang": "ko-kr"}`)
436+
if err != nil {
437+
t.Log(err)
438+
}
439+
xlsx.SetCellStyle("Sheet1", "A2", "A2", style)
440+
441+
style, err = xlsx.NewStyle(`{"number_format": 71, "lang": "th-th"}`)
442+
if err != nil {
443+
t.Log(err)
444+
}
445+
xlsx.SetCellStyle("Sheet1", "A2", "A2", style)
446+
447+
err = xlsx.Save()
448+
if err != nil {
449+
t.Log(err)
450+
}
451+
}
452+
395453
func TestSetCellStyleFill(t *testing.T) {
396454
xlsx, err := OpenFile("./test/Workbook_2.xlsx")
397455
if err != nil {

0 commit comments

Comments
 (0)