Skip to content

Commit

Permalink
Allow invalid cell references when loading xslx files (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardwilkes authored Feb 2, 2024
1 parent fa0eab8 commit f352920
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
9 changes: 5 additions & 4 deletions formats/xlsx/sheet.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright ©2016-2022 by Richard A. Wilkes. All rights reserved.
// Copyright ©2016-2024 by Richard A. Wilkes. All rights reserved.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, version 2.0. If a copy of the MPL was not distributed with
Expand Down Expand Up @@ -156,11 +156,12 @@ func loadSheet(f *zip.File, strs []string) (*Sheet, error) {
if v, err = strconv.Atoi(cell.Value); err != nil {
return nil, errs.Wrap(err)
}
if v < 0 || v >= len(strs) {
return nil, errs.New("String index out of bounds")
if v >= 0 && v < len(strs) {
cell.Value = strs[v]
} else {
cell.Value = "#REF!"
}
cell.Type = String
cell.Value = strs[v]
case "b": // Boolean
cell.Type = Boolean
default: // Number
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21
require (
github.com/jackpal/gateway v1.0.13
github.com/pkg/term v1.1.0
golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
golang.org/x/image v0.15.0
gopkg.in/yaml.v3 v3.0.1
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 h1:hNQpMuAJe5CtcUqCXaWga3FHu+kQvCqcsoVaQgSV60o=
golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA=
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
golang.org/x/image v0.15.0 h1:kOELfmgrmJlw4Cdb7g/QGuB3CvDrXbqEIww/pNtNBm8=
golang.org/x/image v0.15.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
Expand Down

0 comments on commit f352920

Please sign in to comment.