Free Support Forum - aspose.com

Insert chart from excel to word file


#1

Hi Team,


I am aware that, right now there is no feature to create a chart from scratch in aspose.words. however, Can I create a chart using aspose.cells in excel and then insert that chart in word file using aspose.words?
I googled and found that OOXML chart embedding has been fixed in aspose.words but didn’t find any sample code.
If yes then can you share a link or sample code for same.

Regards,
Aditya

#2

Hi Aditya,

Thnaks for your inquiry. Please use DocumentBuilder.InsertOleObject method to insert an embedded OLE object from a stream into the document. Please check the following code example.

Insert embedded Excel 97-2003 document as iconic OLE object from stream using predefined image:

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

Stream memoryStream = File.OpenRead(MyDir + “Book1.xls”);

Shape oleObject = builder.InsertOleObject(memoryStream, “Excel.Sheet.8”, true, null);

doc.Save(MyDir + @“out.docx”);


Please let us know if you need more information, we are always glad to help you.


#3

Hi Tahir,

Thanks for you quick reply. But I want to embed the chart not the whole file. The sample you have provided is for embedding a excel file into word not for chart from an excel.

Is is possible to embed a chart from excel to word (not as an image)?

#4

Hi Aditya,

Thanks for your inquiry. Unfortunately, Aspose.Words does not support the requested feature at the moment. However, I have logged this feature request as WORDSNET-10782 in our issue tracking system. You will be notified via this forum thread once this feature is available.

Could you please share your expected Word document here for our reference along with the Excel document which contains the chart?


#5

Hi,


Thanks for your reply, I am attaching the both files for your reference.

#6

Hi Aditya,

Thanks for sharing the documents. As per my understanding, you are copying the chart from Excel document and paste it into Word document. Please confirm this. Thanks for your cooperation.


#7

I would like to add that I am also looking to add a chart to Word document. Preferably a native Word chart but importing an Excel or Powerpoint Chart would be a short-term workaround.


There are examples of using the Open XML SDK to create a chart. Is there anyway to create the chart XML using that and add it to an Aspose Document Builder (so I wouldn’t need to rewrite all of the code to use the SDK just the chart section).

Thanks,

#8

Yes, but not as an image. I want to copy paste it in native word chart format so that we can edit that chart at later stage in word itself if required.


#9

Hi Aditya,

bradpatton:

I would like to add that I am also looking to add a chart to Word document. Preferably a native Word chart but importing an Excel or Powerpoint Chart would be a short-term workaround.
There are examples of using the Open XML SDK to create a chart. Is there anyway to create the chart XML using that and add it to an Aspose Document Builder (so I wouldn’t need to rewrite all of the code to use the SDK just the chart section).

I am afraid, Aspose.Words currently does not provide API
classes to be able to create charts from scratch and update them with
new values. Your request has been linked to the appropriate issue (WORDSNET-4617) and you will be notified as soon as it is supported. We apologize for your inconvenience.
Adi_evs:

Yes, but not as an image. I want to copy paste it in native word chart format so that we can edit that chart at later stage in word itself if required.

Thanks for sharing this detail. We will update you via this forum thread once WORDSNET-10782 feature is available.

Please let us know if you have any more queries.


#10

The issues you have found earlier (filed as WORDSNET-4617) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(36)

#11

A post was split to a new topic: Working with Excel/Word Charts