diff --git a/calc.go b/calc.go index 59c88852c1..f03c573612 100644 --- a/calc.go +++ b/calc.go @@ -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 { diff --git a/cell.go b/cell.go index 721ba7bc01..5d547e814a 100644 --- a/cell.go +++ b/cell.go @@ -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 }) } diff --git a/col.go b/col.go index b51a283a43..c51fdada3a 100644 --- a/col.go +++ b/col.go @@ -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 } diff --git a/excelize.go b/excelize.go index b86957247b..152e21222d 100644 --- a/excelize.go +++ b/excelize.go @@ -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 } @@ -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 } diff --git a/file.go b/file.go index 894dd0ab9d..067f9997cc 100644 --- a/file.go +++ b/file.go @@ -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 } diff --git a/rows.go b/rows.go index b87d45dddf..7541a0b217 100644 --- a/rows.go +++ b/rows.go @@ -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 }