diff options
author | jinhyuk-kim-ca <71794373+jinhyuk-kim-ca@users.noreply.github.com> | 2020-09-27 01:34:39 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-27 13:34:39 +0800 |
commit | c49222023756d6740877f286cb7d3e7a5a0950eb (patch) | |
tree | 8521c01dcc2b1876b16cbda2c39fe6f70640c413 /pivotTable.go | |
parent | 89465f41b5a29ac2e1debe16b8cb6f59c344f917 (diff) |
Pivot table generation fails when no Columns and multiple Data are provided. (#708)
fix to create pivot table in case there is no input from Columns
Co-authored-by: Jin Kim <jinhyuk.kim@cerence.com>
Co-authored-by: xuri <xuri.me@gmail.com>
Diffstat (limited to 'pivotTable.go')
-rw-r--r-- | pivotTable.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/pivotTable.go b/pivotTable.go index 0c1dd61..a197c1f 100644 --- a/pivotTable.go +++ b/pivotTable.go @@ -460,6 +460,15 @@ func inPivotTableField(a []PivotTableField, x string) int { // definition and option. func (f *File) addPivotColFields(pt *xlsxPivotTableDefinition, opt *PivotTableOption) error { if len(opt.Columns) == 0 { + if len(opt.Data) <= 1 { + return nil + } + pt.ColFields = &xlsxColFields{} + // in order to create pivot table in case there is no input from Columns + pt.ColFields.Count = 1 + pt.ColFields.Field = append(pt.ColFields.Field, &xlsxField{ + X: -2, + }) return nil } |