Free Support Forum - aspose.com

Issue in editing external links in charts(Aspose.slides)

We are using Aspose for generating powerpoint presentation. We have a template which is the model of the presentation. The data for the presentation is present in an excel file and based on the excel file data it will update the charts on slides. As of now we use interop and open xml to get this done.

Now migrating to Aspose and I created the excel file. Now the issue is that I need to establish the link
Below is the open XML code written to get this done.

public void ReplaceExcelLinkInPptx(string pptxfile, string externalExcel)
{
string folder = System.IO.Path.GetDirectoryName(externalExcel);
string name = System.IO.Path.GetFileName(externalExcel);
externalExcel = string.Format(@"{0}{1}", folder, UrlEncode(name));
using (PresentationDocument myPptx = PresentationDocument.Open(pptxfile, true))
{
PresentationPart pres_part = myPptx.PresentationPart;
foreach (SlidePart slide_part in pres_part.SlideParts)
{
ReplacePartExternalRelationships(slide_part, externalExcel);
foreach (ChartPart chart_part in slide_part.ChartParts)
{
ReplacePartExternalRelationships(chart_part, externalExcel);
}
}
pres_part.Presentation.Save();
myPptx.Close();
}
}

private void ReplacePartExternalRelationships(OpenXmlPart part, string externalExcel)
{
Dictionary<string, string> rids = new Dictionary<string, string>();
foreach (ExternalRelationship er in part.ExternalRelationships)
{
if (er.Uri.IsFile)
{
rids.Add(er.Id, er.Uri.ToString());
}
}
foreach (var rid in rids)
{
part.DeleteExternalRelationship(rid.Key);
int p = rid.Value.IndexOf(’!’);
if (p >= 0)
{
part.AddExternalRelationship(
http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject”,
new Uri(string.Format(@“file:///{0}{1}”, externalExcel, rid.Value.Substring§)), rid.Key);
}
else
{
part.AddExternalRelationship(
http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject”,
new Uri(string.Format(@“file:///{0}”, externalExcel)), rid.Key);
}

        }
    }

can you tell me how we can perform this using aspose.net

@thomas2709 ,

Thanks for showing interest in Aspose.Slides.

I have tried understanding the sample code shared by you and have not been able to completely understand your requirement from shared sample code. Do you need to set a excel workbook as data source for chart in presentation slide? Can you please elaborate your requirement along with source template presentation, used excel files and desired output presentation. I will try my best to help you further in this regard.

Many Thanks,

Mudassir Fayyaz

Yes… We have a template set up for generating the slides which already have a chart based on excel data. And the charts are based on excel data, that means the charts are linked with excel.
First I will update the excel data and the charts will be automatically updated. Right now what happens is we use open office to update the links and then I open the slide using Aspose for copying some other operation. While saving the slide using Aspose, we loose the link to the charts and the changes based on new excel data is lost.

Basically the external link to the charts are not saved while saving the slides using Aspose…

@thomas2709,

I have observed your requirements and regret to share that at present the support for setting the external workbook as chart data source is unavailable in Aspose.Slides for .NET. An issue with ID SLIDESNET-39057 has been created in our issue tracking system to further investigate the possibility of implementing requested support.

However, if you have a presentation with chart having external workbook as chart data source and you are interested in getting that, you can get that by using sample code given over this documentation link.

We are sorry for your inconvenience,

Many Thanks,

Thanks for you reply. Please keep me posted whenever you add this feature in the product

@thomas2709,

Sure, we will share the notification with you once the support will be available in API.

Many Thanks,

Mudassir Fayyaz