From 32b23ef42d3ecb393e102c5f63ab5125db354435 Mon Sep 17 00:00:00 2001
From: xuri <xuri.me@gmail.com>
Date: Sun, 5 Sep 2021 11:59:50 +0800
Subject: This closes #998

- Support text comparison in the formula, also ref #65
- `GetCellValue`, `GetRows`, `GetCols`, `Rows` and `Cols` support to specify read cell with raw value, ref #621
- Add missing properties for the cell formula
- Update the unit test for the `CalcCellValue`
---
 excelize.go | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

(limited to 'excelize.go')

diff --git a/excelize.go b/excelize.go
index 11ddf92..def018b 100644
--- a/excelize.go
+++ b/excelize.go
@@ -58,9 +58,12 @@ type File struct {
 
 type charsetTranscoderFn func(charset string, input io.Reader) (rdr io.Reader, err error)
 
-// Options define the options for open spreadsheet.
+// Options define the options for open and reading spreadsheet. RawCellValue
+// specify if apply the number format for the cell value or get the raw
+// value.
 type Options struct {
 	Password       string
+	RawCellValue   bool
 	UnzipSizeLimit int64
 }
 
@@ -119,11 +122,9 @@ func OpenReader(r io.Reader, opt ...Options) (*File, error) {
 		return nil, err
 	}
 	f := newFile()
-	for i := range opt {
-		f.options = &opt[i]
-		if f.options.UnzipSizeLimit == 0 {
-			f.options.UnzipSizeLimit = UnzipSizeLimit
-		}
+	f.options = parseOptions(opt...)
+	if f.options.UnzipSizeLimit == 0 {
+		f.options.UnzipSizeLimit = UnzipSizeLimit
 	}
 	if bytes.Contains(b, oleIdentifier) {
 		b, err = Decrypt(b, f.options)
@@ -150,6 +151,16 @@ func OpenReader(r io.Reader, opt ...Options) (*File, error) {
 	return f, nil
 }
 
+// parseOptions provides a function to parse the optional settings for open
+// and reading spreadsheet.
+func parseOptions(opts ...Options) *Options {
+	opt := &Options{}
+	for _, o := range opts {
+		opt = &o
+	}
+	return opt
+}
+
 // CharsetTranscoder Set user defined codepage transcoder function for open
 // XLSX from non UTF-8 encoding.
 func (f *File) CharsetTranscoder(fn charsetTranscoderFn) *File { f.CharsetReader = fn; return f }
-- 
cgit v1.2.1