From c49222023756d6740877f286cb7d3e7a5a0950eb Mon Sep 17 00:00:00 2001 From: jinhyuk-kim-ca <71794373+jinhyuk-kim-ca@users.noreply.github.com> Date: Sun, 27 Sep 2020 01:34:39 -0400 Subject: 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 Co-authored-by: xuri --- pivotTable.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'pivotTable.go') 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 } -- cgit v1.2.1