Skip to content

Commit 8152bbb

Browse files
committed
This closes qax-os#1312, qax-os#1313, fix number format issue
- Add supported options in the docs of the functions `SetSheetPrOptions` and `GetSheetPrOptions` - Add go1.19 unit test settings, and made the test case compatible with go1.19 - Update dependencies module
1 parent ed91cdd commit 8152bbb

File tree

7 files changed

+35
-21
lines changed

7 files changed

+35
-21
lines changed

.github/workflows/go.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
test:
66
strategy:
77
matrix:
8-
go-version: [1.15.x, 1.16.x, 1.17.x, 1.18.x]
8+
go-version: [1.15.x, 1.16.x, 1.17.x, 1.18.x, 1.19.x]
99
os: [ubuntu-latest, macos-latest, windows-latest]
1010
targetplatform: [x86, x64]
1111

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ require (
1010
github.com/stretchr/testify v1.7.1
1111
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470
1212
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22
13-
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d
13+
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa
1414
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9
15-
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e
15+
golang.org/x/net v0.0.0-20220809184613-07c6da5e1ced
1616
golang.org/x/text v0.3.7
1717
gopkg.in/yaml.v3 v3.0.0 // indirect
1818
)

go.sum

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 h1:6932x8ltq1w4utjmfMPVj0
1717
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
1818
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 h1:OAmKAfT06//esDdpi/DZ8Qsdt4+M5+ltca05dA5bG2M=
1919
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ=
20-
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY=
21-
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
20+
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c=
21+
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
2222
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9 h1:LRtI4W37N+KFebI/qV0OFiLUv4GLOWeEW5hn/KEJvxE=
2323
golang.org/x/image v0.0.0-20220413100746-70e8d0d3baa9/go.mod h1:023OzeP/+EPmXeapQh35lcL3II3LrY8Ic+EFFKVhULM=
2424
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
25-
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e h1:TsQ7F31D3bUCLeqPT0u+yjp1guoArKaNKmCr22PYgTQ=
26-
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
25+
golang.org/x/net v0.0.0-20220809184613-07c6da5e1ced h1:3dYNDff0VT5xj+mbj2XucFst9WKk6PdGOrb9n+SbIvw=
26+
golang.org/x/net v0.0.0-20220809184613-07c6da5e1ced/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
2727
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
2828
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
2929
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
30-
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
30+
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
3131
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
3232
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
3333
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=

lib_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"io"
99
"os"
10+
"runtime"
1011
"strconv"
1112
"strings"
1213
"sync"
@@ -340,6 +341,9 @@ func TestReadBytes(t *testing.T) {
340341
}
341342

342343
func TestUnzipToTemp(t *testing.T) {
344+
if strings.HasPrefix(runtime.Version(), "go1.19") {
345+
t.Skip()
346+
}
343347
os.Setenv("TMPDIR", "test")
344348
defer os.Unsetenv("TMPDIR")
345349
assert.NoError(t, os.Chmod(os.TempDir(), 0o444))

numfmt.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ func (nf *numberFormat) positiveHandler() (result string) {
337337
nf.result += token.TValue
338338
continue
339339
}
340-
if token.TType == nfp.TokenTypeZeroPlaceHolder && token.TValue == "0" {
340+
if token.TType == nfp.TokenTypeZeroPlaceHolder && token.TValue == strings.Repeat("0", len(token.TValue)) {
341341
if isNum, precision := isNumeric(nf.value); isNum {
342342
if nf.number < 1 {
343343
nf.result += "0"
@@ -899,7 +899,7 @@ func (nf *numberFormat) negativeHandler() (result string) {
899899
nf.result += token.TValue
900900
continue
901901
}
902-
if token.TType == nfp.TokenTypeZeroPlaceHolder && token.TValue == "0" {
902+
if token.TType == nfp.TokenTypeZeroPlaceHolder && token.TValue == strings.Repeat("0", len(token.TValue)) {
903903
if isNum, precision := isNumeric(nf.value); isNum {
904904
if math.Abs(nf.number) < 1 {
905905
nf.result += "0"

rows_test.go

+13-11
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,19 @@ func TestRowsGetRowOpts(t *testing.T) {
107107
rows, err := f.Rows(sheetName)
108108
require.NoError(t, err)
109109

110-
rows.Next()
111-
rows.Columns() // Columns() may change the XML iterator, so better check with and without calling it
112-
got := rows.GetRowOpts()
113-
assert.Equal(t, expectedRowStyleID1, got)
114-
rows.Next()
115-
got = rows.GetRowOpts()
116-
assert.Equal(t, expectedRowStyleID2, got)
117-
rows.Next()
118-
rows.Columns()
119-
got = rows.GetRowOpts()
120-
assert.Equal(t, expectedRowStyleID3, got)
110+
assert.Equal(t, true, rows.Next())
111+
_, err = rows.Columns()
112+
require.NoError(t, err)
113+
rowOpts := rows.GetRowOpts()
114+
assert.Equal(t, expectedRowStyleID1, rowOpts)
115+
assert.Equal(t, true, rows.Next())
116+
rowOpts = rows.GetRowOpts()
117+
assert.Equal(t, expectedRowStyleID2, rowOpts)
118+
assert.Equal(t, true, rows.Next())
119+
_, err = rows.Columns()
120+
require.NoError(t, err)
121+
rowOpts = rows.GetRowOpts()
122+
assert.Equal(t, expectedRowStyleID3, rowOpts)
121123
}
122124

123125
func TestRowsError(t *testing.T) {

sheetpr.go

+8
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ func (o *AutoPageBreaks) getSheetPrOption(pr *xlsxSheetPr) {
242242
// EnableFormatConditionsCalculation(bool)
243243
// Published(bool)
244244
// FitToPage(bool)
245+
// TabColorIndexed(int)
246+
// TabColorRGB(string)
247+
// TabColorTheme(int)
248+
// TabColorTint(float64)
245249
// AutoPageBreaks(bool)
246250
// OutlineSummaryBelow(bool)
247251
func (f *File) SetSheetPrOptions(sheet string, opts ...SheetPrOption) error {
@@ -268,6 +272,10 @@ func (f *File) SetSheetPrOptions(sheet string, opts ...SheetPrOption) error {
268272
// EnableFormatConditionsCalculation(bool)
269273
// Published(bool)
270274
// FitToPage(bool)
275+
// TabColorIndexed(int)
276+
// TabColorRGB(string)
277+
// TabColorTheme(int)
278+
// TabColorTint(float64)
271279
// AutoPageBreaks(bool)
272280
// OutlineSummaryBelow(bool)
273281
func (f *File) GetSheetPrOptions(sheet string, opts ...SheetPrOptionPtr) error {

0 commit comments

Comments
 (0)