Free Support Forum - aspose.com

Scattered plot chart opened with Aspose.Cells and exported in DOCX using OpenXML - chart is generated incorrectly after saving with OoxmlSaveOptions.RefreshChartCache = true

Hi,

This issue seems related to CELLSNET-43500 but it’s not the same because in this case we don’t get any NullRefrenceException.
When opening the attached Excel file with Aspose.Cells, saving to a stream using OoxmlSaveOptions.RefreshChartCache = true then exporting the chart to Word using OpenXML the aspect of the chart is affected. This is not happening if we don’t use RefreshChartCache = true. If we save the content of the stream to a file as byte array Excel will report the file is corrupted and after repairing the chart is removed.
All these scanarios are working fine as long as we don’t use RefreshChartCache = true.
For reproducing the issue plase use the attached files and the following code:

using (var conversionStream = new MemoryStream())
{
var sourceWorkbook = new Workbook(“source.xlsx”);
var saveOptions = new OoxmlSaveOptions(SaveFormat.Xlsx) {RefreshChartCache = true};
sourceWorkbook.Save(conversionStream, saveOptions);
//then using OpenXML here to export the chart to Word;
//the result of the export is in the attached Word document;
//everything is fine if we don’t use RefreshChartCache = true

//Saving the content to a file as byte array;
//Excel will report the file is corrupted and after repairing the chart is removed
File.WriteAllBytes(“output.xlsx”, conversionStream.ToArray());
}

If more details/clarifications are needed please let me know, thanks.

Best regards,
Aurelian Iordache
Software Developer
IBM Romania

Hi Aurelian,


Thank you for contacting Aspose support.

I have evaluated a part of your presented scenario by re-saving the Source.xlsx to MemoryStream and then writing the bytes to file while setting the OoxmlSaveOptions.RefreshChartCache to true (your provided code snippet). The resultant spreadsheet can be opened with Excel (2013) without repair and the chart on the worksheet OEMTelecomBub remains intact. Please note, I have used the latest version of Aspose.Cells for .NET 8.4.0.1 for the testing, and it seems the issue is already resolved with this revision. Please try it on your end as well.

I hope your main scenario (exporting the chart to Word document with OpenXML) will work fine with the latest version. In case the problem persists, please provide us an executable sample application covering your complete scenario along with the project dependencies for further investigation.

Hi Babar,

I checked with Aspose.Cells v.8.4.1.0 and there is still a issue with the aspect of the chart exported to Word. Unfortunately I can’t provide the code we use for OpenXML export to Word because I don’t have approval to do this but I’ll try to explain the problem here.
Please use the attached XLSX file and the following code:

private static void Main()
{
//path to the Excel file containing the chart we will export to Word
const string sourceFileExcel = “BubbleTest.xlsx”;
var content = File.ReadAllBytes(sourceFileExcel);

var resultForRefreshChartCacheTrue = RefreshWorbookChartCache(content, true);
File.WriteAllBytes(“resultForRefreshChartCacheTrue.xlsx”, resultForRefreshChartCacheTrue);

var resultForRefreshChartCacheFalse = RefreshWorbookChartCache(content, false);
File.WriteAllBytes(“resultForRefreshChartCacheFalse.xlsx”, resultForRefreshChartCacheFalse);
}

private static byte[] RefreshWorbookChartCache(byte[] workbookContent, bool refreshChartCache)
{
using (var conversionStream = new MemoryStream())
{
using (var tempStream = new MemoryStream(workbookContent))
{
var asposeDocument = new Workbook(tempStream);
var saveOptions = new OoxmlSaveOptions(SaveFormat.Xlsx) { RefreshChartCache = refreshChartCache };
asposeDocument.Save(conversionStream, saveOptions);
}
return conversionStream.ToArray();
}
}


Then check the XML difference between the resulted files: in resultForRefreshChartCacheFalse.xlsx we have “c:numCache” while in resultForRefreshChartCacheTrue.xlsx we have “c:strCache” (please see attached XmlIssue.jpg), this seems to make the difference when we use the resulted XLSX files to export to DOCX using OpenXML the chart is generated okay (for “c:numCache”) or wrong (for “c:strCache”).
For reference I’m attaching the resulted DOCX files containing the chart exported using RefreshChartCache set to false and to true (please see attached ExportedWithoutRefreshChartCache.docx and ExportedWithRefreshChartCache.docx).
Actually if we edit the XML in resultForRefreshChartCacheTrue.xlsx and change “c:strCache” to “c:numCache” for a single bubble that respective bubble is positioned correctly in the chart exported to Word (please see attached XmlCorrectedForSingleBubble.jpg).
I’m sorry I can’t provide a full demo code for this one but I have to comply to some restrictions about the code, I hope you understand. Except that code please let me know what other information I can provide.

Thank you,
Aurelian Iordache
Software Developer
IBM Romania

Hi Aurelian,


Thank you for more details.

I hope you can understand that the presented scenario involves multiple APIs therefore it will not be easy to isolate the problem cause, and consequently provide a fix for it without knowing the internal structure of your application, especially how you are exporting the Excel chart to Word document using OpenXML. I would request you to please review the EULA for NDA (clause 8) and forward it to your legal team as well. Once they are satisfied, please share a sample application covering your complete scenario along with its dependencies for further investigation.

By the way, I have checked the case against the latest version of Aspose.Cells for .NET 8.4.1.5, and upon reviewing the chart1.xml file, I have noticed that the XML uses c:numCache instead of c:strCache for both cases, that is; with or without setting the OoxmlSaveOptions.RefreshChartCache property to true while re-saving your provided sample spreadsheet. Please evaluate your complete scenario against the latest version and let us know of your feedback.

Hi again,


This is to inform you that upon discussion with the product team on this matter, we have logged a format investigative request in our database under the ticket CELLSNET-43657. We will analyze your presented scenario thoroughly and will keep you posted with updates in this regard. In the meantime, I hope you can get an approval to share a standalone executable sample application for our review.

Hi Babar,

I evaluated Aspose.Cells v.8.4.1.5 but when using RefreshChartCache=true it still generates c:strRef respectively c:strCache in the generated XML, could you please check again ? That branch is starting at line 72 in chart1.xml, I’m attaching a screenshot here.
About the corporate agreement we have - thank you for letting me know about this, especially about point 8 (“Nondisclosure”), I’ll ask again for approval to send to you a full demo project containing our scenario, I’ll keep you updated here.

Best regards,
Aurelian Iordache
Software Developer
IBM Romania

Hi Aurelian,


Thank you for highlighting the line number. I have reevaluated the case while using the latest version of Aspose.Cells for .NET 8.4.2, and was able to notice the difference in XML files generated with and without setting the chart caching. I believe the difference was reproducible with v8.4.1.5 as well however, I may be looking at the wrong place. Please accept my apologies for that.

I have recorded my recent observations to the ticket CELLSNET-43657, and have requested the product team to schedule this incident for analysis at earliest possible. As soon as we have any updates, we will post here for your kind reference.

Hi Babar,

Thank you very much, no apologies are necessary.
We will expect the result of the analysis when it’s available, please keep us updated here.

Best regards,
Aurelian Iordache
Software Developer
IBM Romania

Hi Aurelian,


Thank you. Please note that the ticket logged earlier as CELLSNET-43657 has been resolved by the product team, and we will shortly provide the fix after performing QA & incorporating other enhancements.

Hi,

Thanks for your using Aspose.Cells.

Please download and try the latest fix: Aspose.Cells for .NET v8.4.2.1 and let us know your feedback.

Hi Shakeel,

We tested with the fix and the chart is looking good now.
So I suppose this fix will be included in the next release.
Thank you very much :slight_smile:

Best regards,
Aurelian Iordache
Software Developer
IBM Romania

Hi Aurelian,


Thank you for the confirmation. Yes, the fix will be included in the upcoming major release of Aspose.Cells for .NET 4.5.0 that is scheduled for the month of June. You will be formally notified here once the next major release is available for public use.

The issues you have found earlier (filed as CELLSNET-43657) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.