Skip to content

Commit

Permalink
This closes qax-os#1815, cell value reading functions inherit the Opt…
Browse files Browse the repository at this point in the history
…ions settings of the OpenReader (qax-os#1816)

Co-authored-by: Vivek Kairi <[email protected]>
  • Loading branch information
vivekkairi and Vivek Kairi authored Feb 15, 2024
1 parent 9cbe3b6 commit ee2ef15
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
5 changes: 3 additions & 2 deletions calc.go
Original file line number Diff line number Diff line change
Expand Up @@ -805,14 +805,15 @@ type formulaFuncs struct {
// Z.TEST
// ZTEST
func (f *File) CalcCellValue(sheet, cell string, opts ...Options) (result string, err error) {
options := f.getOptions(opts...)
var (
rawCellValue = getOptions(opts...).RawCellValue
rawCellValue = options.RawCellValue
styleIdx int
token formulaArg
)
if token, err = f.calcCellValue(&calcContext{
entry: fmt.Sprintf("%s!%s", sheet, cell),
maxCalcIterations: getOptions(opts...).MaxCalcIterations,
maxCalcIterations: options.MaxCalcIterations,
iterations: make(map[string]uint),
iterationsCache: make(map[string]formulaArg),
}, sheet, cell); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cell.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (f *File) GetCellValue(sheet, cell string, opts ...Options) (string, error)
if err != nil {
return "", true, err
}
val, err := c.getValueFrom(f, sst, getOptions(opts...).RawCellValue)
val, err := c.getValueFrom(f, sst, f.getOptions(opts...).RawCellValue)
return val, true, err
})
}
Expand Down
2 changes: 1 addition & 1 deletion col.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (cols *Cols) Rows(opts ...Options) ([]string, error) {
if cols.stashCol >= cols.curCol {
return rowIterator.cells, rowIterator.err
}
cols.rawCellValue = getOptions(opts...).RawCellValue
cols.rawCellValue = cols.f.getOptions(opts...).RawCellValue
if cols.sst, rowIterator.err = cols.f.sharedStringsReader(); rowIterator.err != nil {
return rowIterator.cells, rowIterator.err
}
Expand Down
6 changes: 3 additions & 3 deletions excelize.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func OpenReader(r io.Reader, opts ...Options) (*File, error) {
return nil, err
}
f := newFile()
f.options = getOptions(opts...)
f.options = f.getOptions(opts...)
if err = f.checkOpenReaderOptions(); err != nil {
return nil, err
}
Expand Down Expand Up @@ -219,8 +219,8 @@ func OpenReader(r io.Reader, opts ...Options) (*File, error) {

// getOptions provides a function to parse the optional settings for open
// and reading spreadsheet.
func getOptions(opts ...Options) *Options {
options := &Options{}
func (f *File) getOptions(opts ...Options) *Options {
options := f.options
for _, opt := range opts {
options = &opt
}
Expand Down
2 changes: 1 addition & 1 deletion file.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewFile(opts ...Options) *File {
ws, _ := f.workSheetReader("Sheet1")
f.Sheet.Store("xl/worksheets/sheet1.xml", ws)
f.Theme, _ = f.themeReader()
f.options = getOptions(opts...)
f.options = f.getOptions(opts...)
return f
}

Expand Down
2 changes: 1 addition & 1 deletion rows.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (rows *Rows) Columns(opts ...Options) ([]string, error) {
}
var rowIterator rowXMLIterator
var token xml.Token
rows.rawCellValue = getOptions(opts...).RawCellValue
rows.rawCellValue = rows.f.getOptions(opts...).RawCellValue
if rows.sst, rowIterator.err = rows.f.sharedStringsReader(); rowIterator.err != nil {
return rowIterator.cells, rowIterator.err
}
Expand Down

0 comments on commit ee2ef15

Please sign in to comment.