diff options
author | xuri <xuri.me@gmail.com> | 2021-09-05 11:59:50 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2021-09-05 11:59:50 +0800 |
commit | 32b23ef42d3ecb393e102c5f63ab5125db354435 (patch) | |
tree | e73ec4e2e062d15ca6d53407039ddb3004942995 /excelize.go | |
parent | 2616aa88cb2b1e45c03ada60093f4dfe7fabfb87 (diff) |
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`
Diffstat (limited to 'excelize.go')
-rw-r--r-- | excelize.go | 23 |
1 files changed, 17 insertions, 6 deletions
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 } |