This project has moved. For the latest updates, please go here.

Pivot Tables - Refresh on Load

Oct 18, 2013 at 9:20 AM
Edited Oct 18, 2013 at 9:21 AM
I'm creating spreadsheets based on existing templates (see the code sample below) and want to ensure that any Pivot Tables in the output have their "Refresh data when opening the file" property (from the Data tab in the Pivot Table's options dialog) set to true.
public static void foo(string templatePath, System.IO.Stream outputStream)
{
    using (var templateStream = System.IO.File.OpenRead(templatePath))
    {
        using (var xlsx = new ExcelPackage(outputStream, templateStream))
        {
            foreach (var ws in xlsx.Workbook.Worksheets)
            {
                foreach (var pt in ws.PivotTables)
                {
                    // TODO... Ensure that "Refresh data when opening the file" is set to true
                }
            }
        }
    }
}
I've had a trawl through the object model and spent a while Googling as well, but to no avail. Does anyone know it it's possible to set the value of this property in EPPlus, and if so how?

TIA,

Tony