Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8543159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:14:13+00:00 2026-06-11T12:14:13+00:00

I have to implement a Microsoft Word document generator with embed excel graphics in

  • 0

I have to implement a Microsoft Word document generator with embed excel graphics in it.
One of my constraint is to make my generated docx work both with Microsoft word 2010 and 2003 + compatibility pack.

I didn’t managed to make it works for both of them. I can make it works for Word 2010 but the document are not working for 2003 and vice versa.

After several search to make it work for Word 2003 I have added this in my code :

    private static void Word2003(ChartPart importedChartPart, MainDocumentPart mainDocumentPart, Stream fileStream)
    {
        var ext = new ExternalData { Id = "rel" + 5 };
        importedChartPart.ChartSpace.InsertAt(ext, 3);


        var fi = new FileInfo(@"generated.xlsx");
        importedChartPart.AddExternalRelationship("http://schemas.openxmlformats.org/officeDocument/2006/relationships/package", new Uri(fi.Name, UriKind.Relative), "rel5");

        EmbeddedPackagePart embeddedObjectPart = mainDocumentPart.AddEmbeddedPackagePart(@"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        Stream copyStream = new MemoryStream();
        fileStream.CopyTo(copyStream);
        embeddedObjectPart.FeedData(copyStream);
    }

But at this point generated documents don’t work with Word 2010. If I delete these two lignes :

 var ext = new ExternalData { Id = "rel" + 5 };
 importedChartPart.ChartSpace.InsertAt(ext, 3);

from previous code it’s works for Word 2010 but not for Word 2003.

I have tried several things but I didn’t manage to make it work for each case.

You can find this small piece of code here

The prerequisite is a template of Excel file with a Chart and a graphic in it.


Edit : Generated document always works with Microsoft Office 2007 (with the two problematic code lines or not). I’m still seeking for solutions !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:14:14+00:00Added an answer on June 11, 2026 at 12:14 pm

    I finally found the solution !

    The problem was due to 2 things :
    I didn’t put the External Data correctly and the External relationship was wrong.

    This code make it works :

    private static void Word2003(ChartPart importedChartPart, MainDocumentPart mainDocumentPart, Stream fileStream)
    {
        // Add of the external data id
        ExternalData ext = new ExternalData { Id = "rel" + 5 };
        AutoUpdate autoUpdate = new AutoUpdate{ Val = false};
        ext.Append(autoUpdate);
        importedChartPart.ChartSpace.Append(ext);
    
        // Set of the relationship
        var fi = new FileInfo(@"generated.xlsx");
        importedChartPart.AddExternalRelationship("http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject", new Uri(fi.Name, UriKind.Relative), "rel5");
    
        // Link to the embedded file
        EmbeddedPackagePart embeddedObjectPart = mainDocumentPart.AddEmbeddedPackagePart(@"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
        Stream copyStream = new MemoryStream();
        fileStream.CopyTo(copyStream);
        embeddedObjectPart.FeedData(copyStream);
    }
    

    Now generated Word document works with Word 2003, 2007 and 2010.

    Maybe this will help somebody!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Microsoft Open XML SDK to generate a word document. I have
I have a requirement to implement a toolbar similar to microsoft word 2007 using
Possible Duplicate: How does Microsoft One Note 2010 implement a window that is docked
I'm trying to implement a simple TPH example from http://msdn.microsoft.com/en-us/library/dd793152.aspx . I have two
I have just written a Word Document creation web application using .NET 3.5 which
I have to implement a web service, which takes a Microsoft PowerPoint presentation as
tl;dr Do you need to implement the Microsoft WebDav Extension Properties to properly work
I have implement the exact same concept for my project- http://blog.perplexedlabs.com/2009/05/04/php-jquery-ajax-javascript-long-polling/ My question is,
I have implement a scenario which involves two way communication between child and parent
clients :has_many :project,:roles I have implement but its not a good implementation..

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.