hulk

Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: adding workbook to chart as an embeddedPackagePart #2497

    hulk
    Participant

    Ok, it looks that it is working now, I’ve used below code:

    List<ExternalRelationship> references = chartPart.ExternalRelationships.ToList();
                for (int i = chartPart.ExternalRelationships.Count() - 1; i >= 0; i--)
                {
                    ReferenceRelationship refer = chartPart.ExternalRelationships.ElementAt(i);
                    chartPart.DeleteReferenceRelationship(refer);
                }
                chartPart.ChartSpace.RemoveAllChildren<ExternalData>();
    
                string relationID = "rId99999";
                EmbeddedPackagePart embeddedPackagePart1 = chartPart.AddNewPart<EmbeddedPackagePart>("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", relationID);
                memoryStream.Seek(0, SeekOrigin.Begin);
    
                embeddedPackagePart1.FeedData(memoryStream);
    
                chartPart.CreateRelationshipToPart(embeddedPackagePart1, relationID);
                ExternalData externalData1 = new ExternalData() { Id = relationID };
                AutoUpdate autoUpdate1 = new AutoUpdate() { Val = false };
                externalData1.Append(autoUpdate1);
                chartPart.ChartSpace.Append(externalData1);
    • This reply was modified 8 years, 8 months ago by  hulk.
    • This reply was modified 8 years, 8 months ago by  hulk.
    • This reply was modified 8 years, 8 months ago by  hulk.
    in reply to: adding workbook to chart as an embeddedPackagePart #2496

    hulk
    Participant

    My workbook is now working properly.

    I know how to update data in embedded workbooks, how to do it in external workbooks, but unfortunately I have to embed/attache one to the chart.

    I managed to attach file into presentation package, unfortunately its name is “package.bin” (but when I unzip it then it looks ok), and I still do not know how to set appropriate relations. I have to also delete the old relations to external/embedded workbooks, if they exists.

    I am using below code to attache workbook into presentation package:

                EmbeddedPackagePart embeddedObjectPart =chartPart.AddEmbeddedPackagePart(@"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
    
                embeddedObjectPart.FeedData(File.Open(tempDirectory + "\\sos.xlsx", FileMode.Open,FileAccess.ReadWrite));
Viewing 2 posts - 1 through 2 (of 2 total)