Skip to content

Commit ee2ef15

Browse files
vivekkairiVivek Kairi
andauthored
This closes #1815, cell value reading functions inherit the Options settings of the OpenReader (#1816)
Co-authored-by: Vivek Kairi <[email protected]>
1 parent 9cbe3b6 commit ee2ef15

File tree

6 files changed

+10
-9
lines changed

6 files changed

+10
-9
lines changed

calc.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -805,14 +805,15 @@ type formulaFuncs struct {
805805
// Z.TEST
806806
// ZTEST
807807
func (f *File) CalcCellValue(sheet, cell string, opts ...Options) (result string, err error) {
808+
options := f.getOptions(opts...)
808809
var (
809-
rawCellValue = getOptions(opts...).RawCellValue
810+
rawCellValue = options.RawCellValue
810811
styleIdx int
811812
token formulaArg
812813
)
813814
if token, err = f.calcCellValue(&calcContext{
814815
entry: fmt.Sprintf("%s!%s", sheet, cell),
815-
maxCalcIterations: getOptions(opts...).MaxCalcIterations,
816+
maxCalcIterations: options.MaxCalcIterations,
816817
iterations: make(map[string]uint),
817818
iterationsCache: make(map[string]formulaArg),
818819
}, sheet, cell); err != nil {

cell.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (f *File) GetCellValue(sheet, cell string, opts ...Options) (string, error)
7272
if err != nil {
7373
return "", true, err
7474
}
75-
val, err := c.getValueFrom(f, sst, getOptions(opts...).RawCellValue)
75+
val, err := c.getValueFrom(f, sst, f.getOptions(opts...).RawCellValue)
7676
return val, true, err
7777
})
7878
}

col.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (cols *Cols) Rows(opts ...Options) ([]string, error) {
9292
if cols.stashCol >= cols.curCol {
9393
return rowIterator.cells, rowIterator.err
9494
}
95-
cols.rawCellValue = getOptions(opts...).RawCellValue
95+
cols.rawCellValue = cols.f.getOptions(opts...).RawCellValue
9696
if cols.sst, rowIterator.err = cols.f.sharedStringsReader(); rowIterator.err != nil {
9797
return rowIterator.cells, rowIterator.err
9898
}

excelize.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func OpenReader(r io.Reader, opts ...Options) (*File, error) {
180180
return nil, err
181181
}
182182
f := newFile()
183-
f.options = getOptions(opts...)
183+
f.options = f.getOptions(opts...)
184184
if err = f.checkOpenReaderOptions(); err != nil {
185185
return nil, err
186186
}
@@ -219,8 +219,8 @@ func OpenReader(r io.Reader, opts ...Options) (*File, error) {
219219

220220
// getOptions provides a function to parse the optional settings for open
221221
// and reading spreadsheet.
222-
func getOptions(opts ...Options) *Options {
223-
options := &Options{}
222+
func (f *File) getOptions(opts ...Options) *Options {
223+
options := f.options
224224
for _, opt := range opts {
225225
options = &opt
226226
}

file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func NewFile(opts ...Options) *File {
5050
ws, _ := f.workSheetReader("Sheet1")
5151
f.Sheet.Store("xl/worksheets/sheet1.xml", ws)
5252
f.Theme, _ = f.themeReader()
53-
f.options = getOptions(opts...)
53+
f.options = f.getOptions(opts...)
5454
return f
5555
}
5656

rows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func (rows *Rows) Columns(opts ...Options) ([]string, error) {
151151
}
152152
var rowIterator rowXMLIterator
153153
var token xml.Token
154-
rows.rawCellValue = getOptions(opts...).RawCellValue
154+
rows.rawCellValue = rows.f.getOptions(opts...).RawCellValue
155155
if rows.sst, rowIterator.err = rows.f.sharedStringsReader(); rowIterator.err != nil {
156156
return rowIterator.cells, rowIterator.err
157157
}

0 commit comments

Comments
 (0)