Reputation: 936
Running into two problems that I'm hoping someone can assist.
I am trying to embed a excel 2007 file in relationship with a chart into pptx 2007 programmatically using openxml. I manually created a empty PPTx contains one slide then i did:
EmbeddedPackagePart newEmbeddedPackagePart = slidePart.AddNewPart<EmbeddedPackagePart>("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","rId10");
newEmbeddedPackagePart.FeedData(File.Open(@"C:\Book1.xlsx", FileMode.Open));
Drawing.Charts.ExternalData newEmbeddedPackagePart = new DocumentFormat.OpenXml.Drawing.Charts.ExternalData();
newEmbeddedPackagePart.Id = "rId10";
Which is basically how the SDK code reflector wrote it, save except the binary data was in a string (where I am opening a file). However, this piece of code places a "package.bin" file in xl\drawings\charts\embeddings\ whereas my manual embedding puts the file into ppt\embeddings. Has anyone experienced this problem, and found a way to overcome the incorrect placement of the file, as well as the ".bin" extension?
Thanks in advance!
Upvotes: 1
Views: 2457
Reputation: 936
Just solved the problem by adding 2 lines :)
// Create new Embedded Package Part
EmbeddedPackagePart embPackage = myChartPart.AddNewPart<EmbeddedPackagePart>("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "rId1");
// Feed imported data from an excel file into the embedded package
embPackage.FeedData(new FileStream(@"C:\PATH_TO_FILE\data.xlsx", FileMode.Open, FileAccess.ReadWrite));
Upvotes: 0