Skip to content

Empty columns within the source data range of the pivot table, Excel cannot be opened after setting the pivot table #1945

@ShowerBandV

Description

@ShowerBandV

Description
There are empty columns within the source data range of the pivot table. After setting the pivot table, Excel cannot be opened. After decompressing the Excel file, it was found that the empty cacheField field in pivotCacheDefinition.xml was the cause. Reading the code reveals that it is empty because pc.CacheFields.CacheField.Name directly reads the cell value as empty. Should pc.CacheFields.CacheField.Name be given a default value when the cell value is empty, for example, in the source data of A1~E20, column C is a blank column, and pcCacheFieldsCacheFieldName defaults to column C instead of an empty string

func (f *File) getTableFieldsOrder(opts *PivotTableOptions) ([]string, error) {
	var order []string
	if err := f.getPivotTableDataRange(opts); err != nil {
		return order, err
	}
	dataSheet, coordinates, err := f.adjustRange(opts.pivotDataRange)
	if err != nil {
		return order, newPivotTableDataRangeError(err.Error())
	}
	for col := coordinates[0]; col <= coordinates[2]; col++ {
                //here
		coordinate, _ := CoordinatesToCellName(col, coordinates[1])
		name, err := f.GetCellValue(dataSheet, coordinate)
		if err != nil {
			return order, err
		}
		order = append(order, name)
	}
	return order, nil
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions