summaryrefslogtreecommitdiff
path: root/col.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2021-09-05 11:59:50 +0800
committerxuri <xuri.me@gmail.com>2021-09-05 11:59:50 +0800
commit32b23ef42d3ecb393e102c5f63ab5125db354435 (patch)
treee73ec4e2e062d15ca6d53407039ddb3004942995 /col.go
parent2616aa88cb2b1e45c03ada60093f4dfe7fabfb87 (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 'col.go')
-rw-r--r--col.go10
1 files changed, 6 insertions, 4 deletions
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)
}
}