File tree 2 files changed +11
-13
lines changed
2 files changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -1694,20 +1694,18 @@ func newNumFmt(styleSheet *xlsxStyleSheet, style *Style) int {
1694
1694
1695
1695
// setCustomNumFmt provides a function to set custom number format code.
1696
1696
func setCustomNumFmt (styleSheet * xlsxStyleSheet , style * Style ) int {
1697
- nf := xlsxNumFmt {FormatCode : * style .CustomNumFmt }
1698
-
1699
- if styleSheet .NumFmts != nil {
1700
- nf .NumFmtID = styleSheet .NumFmts .NumFmt [len (styleSheet .NumFmts .NumFmt )- 1 ].NumFmtID + 1
1701
- styleSheet .NumFmts .NumFmt = append (styleSheet .NumFmts .NumFmt , & nf )
1702
- styleSheet .NumFmts .Count ++
1703
- } else {
1704
- nf .NumFmtID = 164
1705
- numFmts := xlsxNumFmts {
1706
- NumFmt : []* xlsxNumFmt {& nf },
1707
- Count : 1 ,
1697
+ nf := xlsxNumFmt {NumFmtID : 163 , FormatCode : * style .CustomNumFmt }
1698
+ if styleSheet .NumFmts == nil {
1699
+ styleSheet .NumFmts = & xlsxNumFmts {}
1700
+ }
1701
+ for _ , numFmt := range styleSheet .NumFmts .NumFmt {
1702
+ if numFmt != nil && nf .NumFmtID < numFmt .NumFmtID {
1703
+ nf .NumFmtID = numFmt .NumFmtID
1708
1704
}
1709
- styleSheet .NumFmts = & numFmts
1710
1705
}
1706
+ nf .NumFmtID ++
1707
+ styleSheet .NumFmts .NumFmt = append (styleSheet .NumFmts .NumFmt , & nf )
1708
+ styleSheet .NumFmts .Count = len (styleSheet .NumFmts .NumFmt )
1711
1709
return nf .NumFmtID
1712
1710
}
1713
1711
Original file line number Diff line number Diff line change @@ -296,7 +296,7 @@ type xlsxNumFmts struct {
296
296
// of a cell.
297
297
type xlsxNumFmt struct {
298
298
NumFmtID int `xml:"numFmtId,attr"`
299
- FormatCode string `xml:"formatCode,attr,omitempty "`
299
+ FormatCode string `xml:"formatCode,attr"`
300
300
FormatCode16 string `xml:"http://schemas.microsoft.com/office/spreadsheetml/2015/02/main formatCode16,attr,omitempty"`
301
301
}
302
302
You can’t perform that action at this time.
0 commit comments