From 32b23ef42d3ecb393e102c5f63ab5125db354435 Mon Sep 17 00:00:00 2001 From: xuri 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` --- col.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'col.go') diff --git a/col.go b/col.go index 1e0c333..5ba5caa 100644 --- a/col.go +++ b/col.go @@ -34,6 +34,7 @@ const ( type Cols struct { err error curCol, totalCol, stashCol, totalRow int + rawCellValue bool sheet string f *File sheetXML []byte @@ -54,14 +55,14 @@ type Cols struct { // fmt.Println() // } // -func (f *File) GetCols(sheet string) ([][]string, error) { +func (f *File) GetCols(sheet string, opts ...Options) ([][]string, error) { cols, err := f.Cols(sheet) if err != nil { return nil, err } results := make([][]string, 0, 64) for cols.Next() { - col, _ := cols.Rows() + col, _ := cols.Rows(opts...) results = append(results, col) } return results, nil @@ -79,7 +80,7 @@ func (cols *Cols) Error() error { } // Rows return the current column's row values. -func (cols *Cols) Rows() ([]string, error) { +func (cols *Cols) Rows(opts ...Options) ([]string, error) { var ( err error inElement string @@ -89,6 +90,7 @@ func (cols *Cols) Rows() ([]string, error) { if cols.stashCol >= cols.curCol { return rows, err } + cols.rawCellValue = parseOptions(opts...).RawCellValue d := cols.f.sharedStringsReader() decoder := cols.f.xmlNewDecoder(bytes.NewReader(cols.sheetXML)) for { @@ -123,7 +125,7 @@ func (cols *Cols) Rows() ([]string, error) { if cellCol == cols.curCol { colCell := xlsxC{} _ = decoder.DecodeElement(&colCell, &xmlElement) - val, _ := colCell.getValueFrom(cols.f, d) + val, _ := colCell.getValueFrom(cols.f, d, cols.rawCellValue) rows = append(rows, val) } } -- cgit v1.2.1