• R/O
  • HTTP
  • SSH
  • HTTPS

excelize: 提交

Go language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets


Commit MetaInfo

修订版cb8bca0e92cbec30db10c2a2863ef81fd98a6138 (tree)
时间2022-08-24 01:00:47
作者xuri <xuri.me@gmai...>
Commiterxuri

Log Message

This closes #1290 and closes #1328

- Add new smooth field in chart format parameter, support specify if smooth line chart
- Fix decimal number format round issue with build-in number format

更改概述

差异

--- a/cell_test.go
+++ b/cell_test.go
@@ -699,6 +699,14 @@ func TestFormattedValue2(t *testing.T) {
699699 })
700700 v = f.formattedValue(1, "43528", false)
701701 assert.Equal(t, "43528", v)
702+
703+ // formatted decimal value with build-in number format ID
704+ styleID, err := f.NewStyle(&Style{
705+ NumFmt: 1,
706+ })
707+ assert.NoError(t, err)
708+ v = f.formattedValue(styleID, "310.56", false)
709+ assert.Equal(t, "311", v)
702710 }
703711
704712 func TestSharedStringsError(t *testing.T) {
--- a/drawing.go
+++ b/drawing.go
@@ -543,9 +543,6 @@ func (f *File) drawLineChart(formatSet *formatChart) *cPlotArea {
543543 },
544544 Ser: f.drawChartSeries(formatSet),
545545 DLbls: f.drawChartDLbls(formatSet),
546- Smooth: &attrValBool{
547- Val: boolPtr(false),
548- },
549546 AxID: []*attrValInt{
550547 {Val: intPtr(754001152)},
551548 {Val: intPtr(753999904)},
@@ -757,6 +754,7 @@ func (f *File) drawChartSeries(formatSet *formatChart) *[]cSer {
757754 DLbls: f.drawChartSeriesDLbls(formatSet),
758755 InvertIfNegative: &attrValBool{Val: boolPtr(false)},
759756 Cat: f.drawChartSeriesCat(formatSet.Series[k], formatSet),
757+ Smooth: &attrValBool{Val: boolPtr(formatSet.Series[k].Line.Smooth)},
760758 Val: f.drawChartSeriesVal(formatSet.Series[k], formatSet),
761759 XVal: f.drawChartSeriesXVal(formatSet.Series[k], formatSet),
762760 YVal: f.drawChartSeriesYVal(formatSet.Series[k], formatSet),
--- a/styles.go
+++ b/styles.go
@@ -852,7 +852,7 @@ func formatToInt(v, format string, date1904 bool) string {
852852 if err != nil {
853853 return v
854854 }
855- return fmt.Sprintf("%d", int64(f))
855+ return fmt.Sprintf("%d", int64(math.Round(f)))
856856 }
857857
858858 // formatToFloat provides a function to convert original string to float
--- a/xmlChart.go
+++ b/xmlChart.go
@@ -620,9 +620,10 @@ type formatChartSeries struct {
620620 Categories string `json:"categories"`
621621 Values string `json:"values"`
622622 Line struct {
623- None bool `json:"none"`
624- Color string `json:"color"`
625- Width float64 `json:"width"`
623+ None bool `json:"none"`
624+ Color string `json:"color"`
625+ Smooth bool `json:"smooth"`
626+ Width float64 `json:"width"`
626627 } `json:"line"`
627628 Marker struct {
628629 Symbol string `json:"symbol"`
Show on old repository browser