We're trying to build a default Excel dashboard which our users can download. When downloading the Excel sheet, we want to populate a sheet in the file with their data.
We're using EPPlus for the manipulation of the Excel sheet.
In short, the structure of the sheet is as follows:
Sheet A
with reporting elements (pivot tables, pivot charts and slicers)Sheet B
which contains the entire data set- A named range defined as
=OFFSET(Data!$A$1;0;0;COUNTA(Data!$A:$A);COUNTA(Data!$1:$1))
which simply adapts to the size of the dataset we insert into that sheet - Whatever the named range contains i loaded into Power Query and added to the workbooks Data Model
- All the reporting elements from
Sheet A
is configured to load data from the Data Model
Overall, this works great as long as we're manually stuffing Sheet B
with our data. When we try to use EPPlus for filling in the data we get an error when trying to save the file:
The cachesource is not a worksheet
By trial and error, we've stripped the sheet of it's parts to isolate the cause of the problem. We suspected that it might have been the slicers, the use of Power Query/Data Model or the trick with the named range. However, none of these looks to be the issue - if we remove all Pivot Tables from the sheet then we're able save the Workbook just fine. Surprising to me, we're able to use the Pivot Charts just fine, it's only the tables which are causing the issue.
Any suggestions as to how to avoid this problem with EPPlus? For now, we've continued without the use of Pivot Tables would we would like to have them return at some point :)