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.Slides for .NET