Skip to content

Commit bebb802

Browse files
authored
This closes qax-os#1999, fix error on GetCellRichText function when read cell without SST index (qax-os#2000)
- Add unit test for get cell rich text when string item index is invalid - Add comments for the variable ErrPasswordLengthInvalid - Update dependencies modules - Update GitHub Actions workflow configuration, test on Go 1.23.x
1 parent 41c7dd3 commit bebb802

File tree

6 files changed

+24
-16
lines changed

6 files changed

+24
-16
lines changed

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
test:
66
strategy:
77
matrix:
8-
go-version: [1.18.x, 1.19.x, 1.20.x, '>=1.21.1', 1.22.x]
8+
go-version: [1.18.x, 1.19.x, 1.20.x, '>=1.21.1', 1.22.x, 1.23.x]
99
os: [ubuntu-latest, macos-13, windows-latest]
1010
targetplatform: [x86, x64]
1111

cell.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,11 +1115,11 @@ func (f *File) GetCellRichText(sheet, cell string) (runs []RichTextRun, err erro
11151115
runs = getCellRichText(c.IS)
11161116
return
11171117
}
1118-
if c.T == "" {
1118+
if c.T != "s" || c.V == "" {
11191119
return
11201120
}
11211121
siIdx, err := strconv.Atoi(c.V)
1122-
if err != nil || c.T != "s" {
1122+
if err != nil {
11231123
return
11241124
}
11251125
sst, err := f.sharedStringsReader()

cell_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,13 @@ func TestGetCellRichText(t *testing.T) {
785785
runs, err = f.GetCellRichText("Sheet1", "A1")
786786
assert.NoError(t, err)
787787
assert.Equal(t, 0, len(runs))
788+
// Test get cell rich text when string item index is invalid
789+
ws, ok = f.Sheet.Load("xl/worksheets/sheet1.xml")
790+
assert.True(t, ok)
791+
ws.(*xlsxWorksheet).SheetData.Row[0].C[0] = xlsxC{T: "s", V: "A", IS: &xlsxSI{}}
792+
runs, err = f.GetCellRichText("Sheet1", "A1")
793+
assert.EqualError(t, err, "strconv.Atoi: parsing \"A\": invalid syntax")
794+
assert.Equal(t, 0, len(runs))
788795
// Test get cell rich text on invalid string item index
789796
ws, ok = f.Sheet.Load("xl/worksheets/sheet1.xml")
790797
assert.True(t, ok)

errors.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ var (
9797
// ErrPasswordLengthInvalid defined the error message on invalid password
9898
// length.
9999
ErrPasswordLengthInvalid = errors.New("password length invalid")
100-
// ErrPivotTableClassicLayout
100+
// ErrPivotTableClassicLayout defined the error message on enable
101+
// ClassicLayout and CompactData in the same time.
101102
ErrPivotTableClassicLayout = errors.New("cannot enable ClassicLayout and CompactData in the same time")
102103
// ErrSave defined the error message for saving file.
103104
ErrSave = errors.New("no path defined for file, consider File.WriteTo or File.Write")

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ require (
88
github.com/stretchr/testify v1.8.4
99
github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d
1010
github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7
11-
golang.org/x/crypto v0.26.0
11+
golang.org/x/crypto v0.27.0
1212
golang.org/x/image v0.18.0
13-
golang.org/x/net v0.28.0
14-
golang.org/x/text v0.17.0
13+
golang.org/x/net v0.29.0
14+
golang.org/x/text v0.18.0
1515
)
1616

1717
require (
1818
github.com/davecgh/go-spew v1.1.1 // indirect
1919
github.com/pmezard/go-difflib v1.0.0 // indirect
20-
github.com/richardlehane/msoleps v1.0.3 // indirect
20+
github.com/richardlehane/msoleps v1.0.4 // indirect
2121
gopkg.in/yaml.v3 v3.0.1 // indirect
2222
)

go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
77
github.com/richardlehane/mscfb v1.0.4 h1:WULscsljNPConisD5hR0+OyZjwK46Pfyr6mPu5ZawpM=
88
github.com/richardlehane/mscfb v1.0.4/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk=
99
github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
10-
github.com/richardlehane/msoleps v1.0.3 h1:aznSZzrwYRl3rLKRT3gUk9am7T/mLNSnJINvN0AQoVM=
11-
github.com/richardlehane/msoleps v1.0.3/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
10+
github.com/richardlehane/msoleps v1.0.4 h1:WuESlvhX3gH2IHcd8UqyCuFY5yiq/GR/yqaSM/9/g00=
11+
github.com/richardlehane/msoleps v1.0.4/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
1212
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
1313
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
1414
github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d h1:llb0neMWDQe87IzJLS4Ci7psK/lVsjIS2otl+1WyRyY=
1515
github.com/xuri/efp v0.0.0-20240408161823-9ad904a10d6d/go.mod h1:ybY/Jr0T0GTCnYjKqmdwxyxn2BQf2RcQIIvex5QldPI=
1616
github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7 h1:hPVCafDV85blFTabnqKgNhDCkJX25eik94Si9cTER4A=
1717
github.com/xuri/nfp v0.0.0-20240318013403-ab9948c2c4a7/go.mod h1:WwHg+CVyzlv/TX9xqBFXEZAuxOPxn2k1GNHwG41IIUQ=
18-
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
19-
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
18+
golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A=
19+
golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70=
2020
golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ=
2121
golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E=
22-
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
23-
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
24-
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
25-
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
22+
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
23+
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
24+
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
25+
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
2626
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
2727
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2828
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

0 commit comments

Comments
 (0)