Support Center

Welcome back, guest

Register or login below.



Voting closed

Refreshing pivottable's datasource problems

Dir All,

I'm researching and evaluating the features of Gembox.SpreadSheet for new projects. I using an excel template with pivot table (crosstab report). In this sample (, I can not found any methods to perform an action like refreshing data of pivot table (I used named range like data source). I'm looking for an feature can be support in this case. Please help me more information.

Thanks all and best regards,

Sample like this:
// If using Professional version, put your serial key below.

ExcelFile ef = ExcelFile.Load(file, LoadOptions.XlsxDefault);
ExcelWorksheet ws = ef.Worksheets["Data"];

int rowNum = 0;
int colNum = 0;
if(dataSource != null && dataSource.Rows.Count > 0)
int index = 1;
rowNum = dataSource.Rows.Count;
colNum = dataSource.Columns.Count;

foreach (DataRow row in dataSource.Rows)
for (int i = 0; i < dataSource.Columns.Count; i++)
ws.Cells[index, i].Value = row[i];

CellRange range = ws.Cells.GetSubrange(CellRange.RowColumnToPosition(0, 0),
CellRange.RowColumnToPosition(rowNum - 1, colNum - 1));

ws.NamedRanges.Add("PivotData", range);

// How do I refresh an pivot table, it's named PivotTable1, with data source is named PivotData

ef.Save(output, SaveOptions.XlsxDefault);


  • There are no comments.