Go language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets
修订版 | cb8bca0e92cbec30db10c2a2863ef81fd98a6138 (tree) |
---|---|
时间 | 2022-08-24 01:00:47 |
作者 | ![]() |
Commiter | xuri |
@@ -699,6 +699,14 @@ func TestFormattedValue2(t *testing.T) { | ||
699 | 699 | }) |
700 | 700 | v = f.formattedValue(1, "43528", false) |
701 | 701 | 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) | |
702 | 710 | } |
703 | 711 | |
704 | 712 | func TestSharedStringsError(t *testing.T) { |
@@ -543,9 +543,6 @@ func (f *File) drawLineChart(formatSet *formatChart) *cPlotArea { | ||
543 | 543 | }, |
544 | 544 | Ser: f.drawChartSeries(formatSet), |
545 | 545 | DLbls: f.drawChartDLbls(formatSet), |
546 | - Smooth: &attrValBool{ | |
547 | - Val: boolPtr(false), | |
548 | - }, | |
549 | 546 | AxID: []*attrValInt{ |
550 | 547 | {Val: intPtr(754001152)}, |
551 | 548 | {Val: intPtr(753999904)}, |
@@ -757,6 +754,7 @@ func (f *File) drawChartSeries(formatSet *formatChart) *[]cSer { | ||
757 | 754 | DLbls: f.drawChartSeriesDLbls(formatSet), |
758 | 755 | InvertIfNegative: &attrValBool{Val: boolPtr(false)}, |
759 | 756 | Cat: f.drawChartSeriesCat(formatSet.Series[k], formatSet), |
757 | + Smooth: &attrValBool{Val: boolPtr(formatSet.Series[k].Line.Smooth)}, | |
760 | 758 | Val: f.drawChartSeriesVal(formatSet.Series[k], formatSet), |
761 | 759 | XVal: f.drawChartSeriesXVal(formatSet.Series[k], formatSet), |
762 | 760 | YVal: f.drawChartSeriesYVal(formatSet.Series[k], formatSet), |
@@ -852,7 +852,7 @@ func formatToInt(v, format string, date1904 bool) string { | ||
852 | 852 | if err != nil { |
853 | 853 | return v |
854 | 854 | } |
855 | - return fmt.Sprintf("%d", int64(f)) | |
855 | + return fmt.Sprintf("%d", int64(math.Round(f))) | |
856 | 856 | } |
857 | 857 | |
858 | 858 | // formatToFloat provides a function to convert original string to float |
@@ -620,9 +620,10 @@ type formatChartSeries struct { | ||
620 | 620 | Categories string `json:"categories"` |
621 | 621 | Values string `json:"values"` |
622 | 622 | 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"` | |
626 | 627 | } `json:"line"` |
627 | 628 | Marker struct { |
628 | 629 | Symbol string `json:"symbol"` |