@Adhirath
Thank you for your feedback. We will further analyze your issue. We will notify you promptly once there are any updates.
- Can I guess your solution: you have a FlatOPC file with a chart, you want to replace a chart?
- a) If saveOptions.EmbedXlsxAsChartDataSource = false; there is no xlsx data in the docx file.
- b) If true, we will gather data from the chart, export data to xlsx file, then embedded to docx file, In FlatOPC, it should be base 64 encoded.
@Adhirath
I saved xslx as FlatOPC with the following codes:
using (DocumentFormat.OpenXml.Packaging.SpreadsheetDocument spreadsheetDocument = DocumentFormat.OpenXml.Packaging.SpreadsheetDocument.Open(dir + "book1.xlsx", true))
{
XDocument flatOpcDocument = spreadsheetDocument.ToFlatOpcDocument();
flatOpcDocument.Save(dir + "output.flatopc");
}
The directory of xlsx flatopc is different from docx flatopc.
Can you use chart of of xlsx flatopc to implement your request ?
So I tried it out guys, just the option for EmbedXlsxAsChartDataSource is good enough, no need for chart.toOOXML(). Thanks!
@Adhirath
Thank you for your feedback. You are welcome. I am glad that the EmbeddXlsxAsChartDataSource property fully meets your needs. We will notify you promptly once the version v25.9 is released.
Hi guys, I am facing an issue, whenever I mark SaveAsEditableShapes as true I get the error object reference not set to an instance of an object. What could be the reason?
Here is the code-
chartOOXMLCode.zip (932 Bytes)
Thanks for the code segment.
We would appreciate it if you could share a sample project (including complete source code free of compilation errors) along with sample file(s) to help us reproduce the issue on our end. We will review it promptly.
I’ll try to do that, till then is there something I should check that might help with this?
Thank you for your feedback. We cannot locate the issue based solely on the provided code snippets. If you can provide sample files and executable test code, it will be very helpful for us to locate the issue. We will check it soon.
PS. please zip the sample file prior attaching here.
Hi guys, here is the console app. As soon as it hits workbook.Save() I get the null ref error-
Thanks for sharing the sample app with template Excel file.
I am able to reproduce the issue as you mentioned by using your sample project with your template Excel file. I found if we mark SaveAsEditableShapes as “true” I get the error “object reference not set to an instance of an object” upon saving to DOCX. But it works fine if we don’t set the property.
using (var ms = new MemoryStream())
{
var workbook = new Workbook("ChartConsoleExcelSheet.xlsx");
var saveOptions = new DocxSaveOptions();
saveOptions.SaveAsEditableShapes = true;
workbook.Save(ms, saveOptions);//error
}
We require thorough evaluation of the issue. We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSNET-58958
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Can I have an ETA on it? Kinda need this feature urgently. Thanks!
Thank you for bringing this issue to our attention. As it has just been logged, we kindly request a little time (2-3 days) to thoroughly evaluate the issue. Rest assured, we aim to address the problem promptly. We will provide an update here as soon as we have more information.
@Adhirath
We have supported exporting to flatopc files. Please check the attached generate files:
flatopc.zip (10.8 KB)
[Test]
public void CELLSNET58945()
{
Workbook workbook = new Workbook(Constants.sourcePath + "CELLSNET58945.xlsx");
OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();
saveOptions.AsFlatOpc = true;
workbook.Save(Constants.destPath + "CELLSNET58945_Excel.xml", saveOptions);
workbook = new Workbook(Constants.destPath + "CELLSNET58945_Excel.xml");
Assert.AreEqual("a", workbook.Worksheets[0].Cells["A1"].StringValue);
Assert.AreEqual(1, workbook.Worksheets[0].Charts.Count);
}
[Test]
public void CellsNet58945_docx()
{
Workbook workbook = new Workbook(Constants.sourcePath + "CELLSNET58945.xlsx");
DocxSaveOptions saveOptions = new DocxSaveOptions();
saveOptions.AsFlatOpc = true;
saveOptions.SaveAsEditableShapes = true;
saveOptions.EmbedXlsxAsChartDataSource = false;
workbook.Save(Constants.destPath + "CELLSNET58945_word.xml", saveOptions);
String text = File.ReadAllText(Constants.destPath + "CELLSNET58945_word.xml");
Assert.IsTrue(text.IndexOf("chart1.xml") != -1);
Assert.IsTrue(text.IndexOf("xlsx") == -1);
}
Sure, looking forward to it!
does this excel document have a chart? I’m asking because the XML doesn’t house a chart1.xml package.
Moreover, we are pleased to inform you that your issue (Ticket ID: “CELLSNET-58958”) has been resolved. This fix/enhancement will be included in the next release (Aspose.Cells v25.9), which is scheduled for the second week of September 2025. We will contact you again once the new version is available.
looks great, wanted to enquire if there was a way to just include the chart in the doc XML which currently has the table as well. So what I was doing was saving the excel doc as docx and then importing the chart to another doc and then saving that as flatopc to just get the chart related XML data. Is it possible to get the same if I have AsFlatOpc = true and SaveAsEditableShapes = true? it would make more sense according to me.
That’s amazing! What was the issue though if you don’t mind sharing.