Convert excel chart to OOXML

@Adhirath
It’s ok that if we only store const values to chart in the docx file.
We will provide a property similar as DocxSaveOptions.EmbedXlsxAsChartDataSource:

  var wbk1 = new Workbook(dir + "book1.xlsx");
  DocxSaveOptions saveOptions = new DocxSaveOptions();
  saveOptions.SaveAsEditableShapes = true;
  saveOptions.EmbedXlsxAsChartDataSource = false;
  wbk1.Save(dir + "dest.docx", saveOptions);

Please check the following docx without embedding an xlsx file .
dest.docx (13.5 KB)

@Adhirath,

Moreover, for your information, we logged a ticket (Ticket ID: “CELLSNET-58933”) as enhancement to support const values as data source of the chart in the DOCX file for your requirements.

Please note, the new enhancement will be incorporated (sample code already provided in the previous post) in the next release (Aspose.Cells v25.9), which is expected to be released in the first half of September 2025. We will notify you as soon as the new version is released.

You guys are amazing, thanks a ton!!!
So what I’m hearing is if I save the xlsx as docx and have these 2 options as true I can simply extract the chart OOXML ( the drawing part) without needing the table?

@Adhirath
Thank you for your feedback. Your understanding is correct. In the next version v25.9, Aspose.Cells will support store const values to chart in the docx file. We will notify you as soon as the new version v25.9 is released.

Quick question guys, when I see the xml of this dest.docx you shared above I see 2 tables in it and no tag which generally shows up with charts. Is it expected behavior? If it is not too much of a task can you save an excel with a pie chart to docx format and share the file. Thanks!

@Adhirath,

Do you also need the relevant tag(s) to be rendered in the output DOCX? We appreciate if you could share your expected DOCX file. This may help us to achieve your exact requirements. We will look into it soon.

@Adhirath
pie.docx (13.4 KB)

Please check the above pie chart.

I’ll get back to you.

@Adhirath,

Sure, please review the document containing the pie chart at your convenience and then share your feedback with us.

Reference: I’m attaching a Word document that contains a chart along with its complete OOXML structure. Please review the OOXML format in this document - this is exactly how I would like Aspose to generate chart output.
ChartWithRequiredOOXML.zip (33.7 KB)

@Adhirath,

Thank you for sharing the Word document along with the specified OOXML structure. We will thoroughly review it and provide our feedback soon.

@Adhirath
The format in the document is FlatOPC file format, so you just want to export the file as FlatOpc type not docx?
We will look into directly convert Workbook to FlatOPC soon.
And we are thinking about whether we can simply provide a method chart.toOOXML() to return chart1.xml too.

Chart.toOOXML() would be great. So I shared the markup above, I am also sharing the OOXML for the particular chart I shared.
The only difference between this and what I shared is that the above doesn’t have any actual data but this does. So this can be directly inserted into the OOXML of the current document and produce a functioning chart.
InsertedChartXMLWithBinaryData.zip (14.2 KB)

@simon.zhao , Yes actually I just need the FlatOPC for the chart but because that is not directly possible I have to save it as Docx and then extract it.

@Adhirath
If the element of the chart is filled with image, the image fill format will be lost if we only export chart as single chart1.xml with Chart.toOOXML() . And all refers to external resource in the chart will be lost too. Could you accept it?
And could you share your needed part, not whole ooxml(which is a whole word file)?

I would Like to retain as much info as possible. I have shared the exact requirement for a chart in word, it is the minimum required by word to recognize it as a chart. It will have the following -
pkg:name=“/_rels/.rels”
pkg:name=“/word/_rels/document.xml.rels”
pkg:name=“/word/document.xml”
pkg:name=“/word/charts/chart1.xml”
pkg:name=“/word/charts/_rels/chart1.xml.rels”
pkg:name=“/word/embeddings/Microsoft_Excel_Worksheet11.xlsx”

Let me know what you are suggesting

@Adhirath
Thank you for your feedback and detailed information provided. We will further analyze your issue. We will notify you promptly once there are any updates.

1 Like

@Adhirath
Is it ok if we only export content of chart1.xml (<c:chartSpace>…/</c:chartSpace>)? then you can insert it to other flatOPC files or process it by yourself.

I’ll have to try it out. Let me see what gets inserted when I just insert the chartspace.

So if I remove any package part I am unable to insert a editable chart. In that case it would be better for me to just save the file as docx and then extract the required parts from it. The only help I need is to get the embedded worksheet holding the data -pkg:name=“/word/embeddings/Microsoft_Excel_Worksheet11.xlsx.
Do you have any idea on how I could do that?