In a C# environment using these packages
<PackageReference Include="Aspose.Cells" Version="24.10.0" />
<PackageReference Include="Aspose.Slides.NET" Version="24.10.0" />
I have this powerpoint file with 1 slide
slide 4 not updating.zip (5.1 MB)
There is an embedded excel file at the bottom currently reading as “Source: NielsenIQ RMS | L52 w/e…”
However, this is a display that uses some embedded formulas, the result should be something more like “Source: NielsenIQ RMS | YTD w/e…”
If I open the generated file and double click to open the object, it suddenly starts to read as expected. I generally refresh formulas using:
using Aspose.Cells;
using Aspose.Cells.Pivot;
using Aspose.Slides;
List<string> queryKeys = new() { "6780253.SLIDE2147483647_OBJECT 3" };
string directory = @"[directory omitted]\slide 4 not updating.pptx";
using FileStream ReportStream = File.Open(directory, FileMode.Open, FileAccess.ReadWrite);
using Aspose.Slides.Presentation ap = new(ReportStream);
foreach (ISlide slide in ap.Slides)
{
IEnumerable<IShape> potentialCharts = slide.Shapes.Where(s => s is OleObjectFrame);
foreach (IShape slideShape in potentialCharts)
{
if (slideShape is OleObjectFrame ole && !string.IsNullOrEmpty(slideShape.CustomData.Tags["ObjectName"]) && queryKeys.Contains(slideShape.CustomData.Tags["ObjectName"].ToUpper()))
{
ole.GraphicalObjectLock.AspectRatioLocked = false;
using MemoryStream imageStream = new();
using MemoryStream ms = new(ole.EmbeddedData.EmbeddedFileData);
imageStream.Position = 0;
Aspose.Cells.Workbook wb = new(ms);
int activeIndex = wb.Worksheets.ActiveSheetIndex;
CalculationOptions opts = new()
{
CalcStackSize = 5000,
Recursive = true,
IgnoreError = true
};
foreach (Aspose.Cells.Worksheet worksheet1 in wb.Worksheets)
{
worksheet1.RefreshPivotTables();
foreach (PivotTable pTable in worksheet1.PivotTables)
{
pTable.RefreshDataFlag = true;
pTable.RefreshData();
pTable.RefreshDataFlag = false;
pTable.CalculateData();
pTable.RefreshDataOnOpeningFile = true;
pTable.CalculateRange();
}
worksheet1.CalculateFormula(opts, true);
worksheet1.Shapes.UpdateSelectedValue();
foreach (Aspose.Cells.Charts.Chart chart1 in worksheet1.Charts)
{
chart1.RefreshPivotData();
chart1.Shapes.UpdateSelectedValue();
chart1.Calculate();
}
}
wb.CalculateFormula(opts);
}
ap.Save(@"[directory omitted]\abc.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
}
}
is there a step I am missing to “force” the object to update its formula? I know the underlying data is already updated in the “Data” tab but its like the text box is “stuck” on the old value.
@BK.Broiler.730
The workbook is being opened, recalculated and then discarded – the updated bytes are never written back to the OLE object.
After the calculations you must replace the original embedded file data with the new workbook data (and, for safety, mark the object as changed) before saving the presentation.
Minimal change
using (MemoryStream src = new MemoryStream(ole.EmbeddedData.EmbeddedFileData))
{
// open the embedded workbook
var wb = new Aspose.Cells.Workbook(src);
// recalculate everything you need
wb.CalculateFormula(new CalculationOptions { CalcStackSize = 5000, Recursive = true, IgnoreError = true });
// write the updated workbook back to a stream
using (var updated = new MemoryStream())
{
wb.Save(updated, SaveFormat.Xlsx); // or the original format (Xls/Xlsx)
ole.EmbeddedData.EmbeddedFileData = updated.ToArray(); // replace the OLE data
ole.IsObjectDataChanged = true; // optional – forces a refresh
}
}
Then call ap.Save(..., SaveFormat.Pptx); as you already do.
Why this works
ole.EmbeddedData.EmbeddedFileData holds the raw bytes of the embedded Excel file.
- Changing the workbook in memory does not automatically update those bytes.
- Re‑assigning the modified byte array (and optionally setting
IsObjectDataChanged) tells Aspose.Slides that the OLE object has new content, so the displayed text box reflects the latest formula results without the user having to open the object manually.
If you still see the old value after applying the snippet, please provide:
- The exact version of .NET you are targeting (e.g., .NET 6, .NET Framework 4.8).
- A minimal reproducible PPTX (the one you attached is fine) – ensure it contains the same OLE object.
- Any exception or warning messages that appear during
wb.Save or ap.Save.
With that information we can verify whether any additional steps (e.g., refreshing linked data connections) are required.
@BK.Broiler.730,
I have reproduced the problem you described.
We have opened the following new ticket(s) in our internal issue tracking system and will investigate the case according to the terms mentioned in Free Support Policies.
Issue ID(s): SLIDESNET-45235
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
// write the updated workbook back to a stream
using (var updated = new MemoryStream())
{
wb.Save(updated, SaveFormat.Xlsx); // or the original format (Xls/Xlsx)
ole.EmbeddedData.EmbeddedFileData = updated.ToArray(); // replace the OLE data
ole.IsObjectDataChanged = true; // optional – forces a refresh
}
Two things here, EmbeddedData.EmbeddedFileData is read only at least with the version I am currently using
Property or indexer 'IOleEmbeddedDataInfo.EmbeddedFileData' cannot be assigned to -- it is read only
Also
'OleObjectFrame' does not contain a definition for 'IsObjectDataChanged' and no accessible extension method 'IsObjectDataChanged' accepting a first argument of type 'OleObjectFrame' could be found (are you missing a using directive or an assembly reference?)
It seems a ticket has been opened as a result of this, so I will wait to see the result of that.
@BK.Broiler.730
EmbeddedFileData and IsObjectDataChanged are writable only in the recent Aspose.Slides for .NET releases.
In the version you are using the IOleEmbeddedDataInfo.EmbeddedFileData property is read‑only and the OleObjectFrame.IsObjectDataChanged flag does not exist, which is why the compiler reports the errors you see.
What to do
-
Upgrade to the latest Aspose.Slides for .NET package (e.g. 24.x).
In that version the API looks exactly like the snippet you posted:
using (var updated = new MemoryStream())
{
wb.Save(updated, SaveFormat.Xlsx); // or Xls
ole.EmbeddedData.EmbeddedFileData = updated.ToArray(); // writable
ole.IsObjectDataChanged = true; // forces a refresh
}
-
If you must stay on the older build, use the setter that is available on the embedded‑data object:
using (var updated = new MemoryStream())
{
wb.Save(updated, SaveFormat.Xlsx);
ole.EmbeddedData.SetData(updated.ToArray()); // replaces the OLE bytes
// No IsObjectDataChanged flag – the object will be refreshed
// when the presentation is saved.
}
(The SetData method is present in the older API; it writes the new byte array back to the OLE object.)
-
After updating the embedded workbook, call ap.Save(..., SaveFormat.Pptx) as you already do.
Next steps
- Confirm the exact Aspose.Slides version you are currently referencing (e.g., 22.8, 23.3, etc.).
- If you upgrade and still encounter issues, please attach a minimal PPTX that reproduces the problem and the full stack trace (if any) from
ap.Save.
Once we have the version number and, if needed, a reproducible file, we can verify that the refresh works as expected.
Thank you, I believe we have some paid support but I need to talk to my managers about this.
I do want to ask, when something like this happens, like an element doesn’t update, is there any sort of error that can be thrown to alert us. The problem is if this is a 50+ Slide presentation with many elements, clients often don’t really have the time to check each and every element. I realize this is a long shot, but I had to tell my supervisors that I asked this question.
@BK.Broiler.730,
I’ve updated ticket SLIDESNET-45235 to add your question. Thank you for your patience.