Aspose.Slides for .NET 24.10 Fails to Change Chart Links to Relative

Hi Team,

We are unable to change chart links to relative. This was working till Aspose.Slides 22.2, versions after that we have not been able to do it.

Why does Aspose.Slides force the chart links to absolute if the original chart link is relative?

When we try to set the path to an invalid path, it throws a null exception.

There was a null exception thrown when trying to open a certain file, this null exception issue was fixed in Aspose.Slides 23.1, but we cannot update to that version because we will lose the ability to set the path to relative (since Aspose.Slides 22.2 change). This was reported to Aspose in the beginning of February 2023. Here is a link to that Aspose forum ticket, Aspose.Slides for .NET 22.2 Throws an Object Null Reference Exception.

We created a sample project demonstrating this behavior. The sample project uses Aspose.Slides 24.10.
AsposeSlidesSetChartLinkToRelative.7z (34.9 KB)

@vikram.venugopal,
Thank you for describing the issue. I’ve reproduced the problem you described.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESNET-44732

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.

The issues you found earlier (filed as SLIDESNET-44732) have been fixed in Aspose.Slides for .NET 25.1 (ZIP, MSI, NuGet, Cross-platform).
You can check all fixes on the Release Notes page.
You can also find the latest version of our library on the Product Download page.

@vikram.venugopal,
The reason of forcing the chart links to absolute is described here:

Links to images can be relative, but links to Excel use Object Linking & Embedding (OLE) technology. Unfortunately, OLE insists on full paths; it doesn’t permit relative paths.

So specifying a relative path breaks the chart links. This problem has been fixed by a full path setting.

But if the chart links to the file in the same folder as the presentation file then PowerPoint will find it because:

PowerPoint will look first for the linked file along the full path to the file that’s part of the link.
If it doesn’t find the file there, it will look in the current directory (ie, the same directory/folder as the PowerPoint file is stored in. Usually.)

This behavior has been added to Aspose.Slides for .NET 25.1.

We tested out Aspose.Slides for .NET 25.1 and here are our findings.

  1. Still, we are unable to set the path to relative, when we do, the path must be relative to the EXE path (LinkFixer Advanced in our case) and Aspose converts it to absolute. When we re-retrieve it, we find only the absolute path.
  2. When setting an invalid path, Aspose.Slides still throws an exception.

We are unable to spot the difference between the new Aspose.Slides version and the older one we reported the issue on.

OLE objects can have both the absolute and relative link to a file, if we do not set the absolute, the relative path will keep working fine, but Aspose doesn’t give us the ability to do so.

@LinkTek1,
Thank you for the message. I need some time to check the problem. I will get back to you soon.

@LinkTek1,

In Aspose.Slides for .NET 25.1, the behavior of file links is implemented according to the information provided above.

Could you please describe the expected result when setting an invalid file path?

Unfortunately, I could not find any information to support this claim. PowerPoint does not directly support relative paths in the usual sense (like in HTML or other systems), and by default all links to external objects in a presentation are saved as absolute. PowerPoint does not officially provide a simple switch to make all links strictly relative.

“Could you please describe the expected result when setting an invalid file path?”

If Aspose is not going to allow setting invalid/broken links, can we at least get a meaningful exception (e.g. AsopseCantSetBorkenLinkException) instead of the NullReferenceException so we can catch it in the code and handle it properly?

“Unfortunately, I could not find any information to support this claim. PowerPoint does not directly support relative paths in the usual sense (like in HTML or other systems), and by default all links to external objects in a presentation are saved as absolute. PowerPoint does not officially provide a simple switch to make all links strictly relative.”

Here is a quote from the Microsoft OLE2 object structure documentation: [MS-OLEDS]: OLEStream
" If the RelativeSourceMonikerStream field is present, it MUST be used by the container application instead of the AbsoluteSourceMonikerStream . If the RelativeSourceMonikerStream field is not present, the AbsoluteSourceMonikerStream MUST be used by the container application."
According to the quote, if we set the relative source moniker stream, PowerPoint should follow the relative path.

@LinkTek1,
Thank you for the information. I will check it and get back to you soon.

@vikram.venugopal,
Thank you for your patience.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): SLIDESNET-44815

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.

Thank you @andrey.potapov.

@LinkTek1,
Thank you for using Aspose.Slides.

The issues you found earlier (filed as SLIDESNET-44815) have been resolved in Aspose.Slides for .NET 25.3 (ZIP, MSI, NuGet, Cross-platform).
You can check all fixes on the Release Notes page.
You can also find the latest version of our library on the Product Download page.

@LinkTek1,
In Aspose.Slides for .NET 25.3, an InvalidOperationException has been added to handle cases when an invalid file path is set.

The documentation you provided only applies to the binary OLE objects in the PPT presentation. However, please note that the Chart is not saved as a binary OLE Stream in the presentation.
The link to the Chart data looks like this:

<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject" Target="file:///C\AsposeSlidesSetChartLinkToRelative\Sample%20Files\Chart.xlsx" TargetMode="External" />

And the Target link to the Excel file must be a full path. It doesn’t permit relative paths.

Thanks for the update @andrey.potapov.

We tried the latest Apsose.Slide 25.3 DLL, now we are getting an InvalidOperationException with the message “External workbook is not available.” when trying to set an invalid path, and we are still unable to set a Chart path to relative.

Here is the XML tag for the relative link.

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
    <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject" Target="Chart.xlsx" TargetMode="External" />
    <Relationship Id="rId2" Type="http://schemas.microsoft.com/office/2011/relationships/chartColorStyle" Target="colors1.xml" />
    <Relationship Id="rId3" Type="http://schemas.microsoft.com/office/2011/relationships/chartStyle" Target="style1.xml" />
</Relationships>

You did mention that PowerPoint cannot have relative links. However, with Aspose.Slides 22.2 we are able to set these target links (chart path) to the Excel file as relative.

@LinkTek1,
Thank you for the message. I am working on the issue and will get back to you soon.

@LinkTek1,
Unfortunately, relative links do not work for charts. To verify this in PowerPoint, please try editing the chart data (the “Edit data” command) in the presentation you created in Aspose.Slides 22.2. You will see a message like the one in the picture:
PowerPoint message

More details: