已验证 提交 bc31e545 编写于 作者: xurime's avatar xurime

- Currency format supported, relate issue #80;

- go test and godoc updated
上级 20aae4e0
......@@ -89,25 +89,16 @@ func parseFormatChartSet(formatSet string) *formatChart {
//
// The following shows the type of chart supported by excelize:
//
// +---------------------------+
// | Type | Chart |
// +==========+================+
// | bar | bar chart |
// +----------+----------------+
// | bar | bar chart |
// | bar3D | 3D bar chart |
// +----------+----------------+
// | doughnut | doughnut chart |
// +----------+----------------+
// | line | line chart |
// +----------+----------------+
// | pie | pie chart |
// +----------+----------------+
// | pie3D | 3D pie chart |
// +----------+----------------+
// | radar | radar chart |
// +----------+----------------+
// | scatter | scatter chart |
// +----------+----------------+
//
// In Excel a chart series is a collection of information that defines which data is plotted such as values, axis labels and formatting.
//
......
......@@ -392,6 +392,64 @@ func TestSetCellStyleNumberFormat(t *testing.T) {
}
}
func TestSetCellStyleCurrencyNumberFormat(t *testing.T) {
xlsx, err := OpenFile("./test/Workbook_3.xlsx")
if err != nil {
t.Log(err)
}
xlsx.SetCellValue("Sheet1", "A1", 56)
xlsx.SetCellValue("Sheet1", "A2", 32.3)
var style int
style, err = xlsx.NewStyle(`{"number_format": 188, "decimal_places": -1}`)
if err != nil {
t.Log(err)
}
xlsx.SetCellStyle("Sheet1", "A1", "A1", style)
style, err = xlsx.NewStyle(`{"number_format": 188, "decimal_places": 31}`)
if err != nil {
t.Log(err)
}
xlsx.SetCellStyle("Sheet1", "A2", "A2", style)
err = xlsx.Save()
if err != nil {
t.Log(err)
}
xlsx, err = OpenFile("./test/Workbook_4.xlsx")
if err != nil {
t.Log(err)
}
xlsx.SetCellValue("Sheet1", "A1", 37947.7500001)
xlsx.SetCellValue("Sheet1", "A2", 37947.7500001)
style, err = xlsx.NewStyle(`{"number_format": 26, "lang": "zh-tw"}`)
if err != nil {
t.Log(err)
}
style, err = xlsx.NewStyle(`{"number_format": 27}`)
if err != nil {
t.Log(err)
}
xlsx.SetCellStyle("Sheet1", "A1", "A1", style)
style, err = xlsx.NewStyle(`{"number_format": 31, "lang": "ko-kr"}`)
if err != nil {
t.Log(err)
}
xlsx.SetCellStyle("Sheet1", "A2", "A2", style)
style, err = xlsx.NewStyle(`{"number_format": 71, "lang": "th-th"}`)
if err != nil {
t.Log(err)
}
xlsx.SetCellStyle("Sheet1", "A2", "A2", style)
err = xlsx.Save()
if err != nil {
t.Log(err)
}
}
func TestSetCellStyleFill(t *testing.T) {
xlsx, err := OpenFile("./test/Workbook_2.xlsx")
if err != nil {
......
此差异已折叠。
......@@ -317,5 +317,7 @@ type formatCellStyle struct {
Vertical string `json:"vertical"`
WrapText bool `json:"wrap_text"`
} `json:"alignment"`
NumFmt int `json:"number_format"`
NumFmt int `json:"number_format"`
DecimalPlaces int `json:"decimal_places"`
Lang string `json:"lang"`
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册