Dear Syncfusion support,
It seems that, if a worksheet contains at least one chart, calling the method "IWorkbook.SaveAsAsync" multiple times results in files that are bigger and bigger. This appears to happen when saving in the Excel2013 XLSX format using XlsIO for WinRT (both v11.2.0.25 and v11.2.0.65).
STEPS TO REPRODUCE:
//Please run the following code for the WinRT platform:
async Task Test()
{
// Create a new workbook:
var excelEngine = new ExcelEngine();
var workbook = excelEngine.Excel.Workbooks.Create();
workbook.Version = ExcelVersion.Excel2013; // Note: This line is important to reproduce the issue.
var worksheet = workbook.Worksheets[0];
// Add some data:
for (int rowIndex = 1; rowIndex < 5; rowIndex++)
worksheet.Range[rowIndex, 1].Value2 = rowIndex;
// Add a chart:
var chart = worksheet.Charts.Add();
chart.DataRange = worksheet.Range["A1:A4"];
// Save the workbook 10 times to a user-selected folder:
var folderPicker = new FolderPicker();
folderPicker.FileTypeFilter.Add(".xlsx");
var destinationFolder = await folderPicker.PickSingleFolderAsync();
if (destinationFolder != null)
{
for (int n = 1; n <= 10; n++)
{
var storageFile = await destinationFolder.CreateFileAsync(string.Format("Test {0}.xlsx", n), CreationCollisionOption.ReplaceExisting);
await workbook.SaveAsAsync(storageFile);
}
}
}
EXPECTED RESULT : The 10 files should be identical and have the same size.
ACTUAL RESULT : The size of the first file is 7KB, the size of the second file is 8KB, etc. The size of the files keep increasing. The size of the last file is 14KB.
This is very annoying because I need to create many XLSX files where each file is slightly different from the previous one, but I end up with files that are bigger and bigger. In case of large files, the delta can be significant. I thought of a workaround that consists in cloning the workbook each time before saving it, but the "IWorkbook.Clone()" method does not seem to work (cf. other forum thread in the same forum category).
Is there any workaround for saving a workbook (with charts) to XLSX multiple times without causing its size to keep increasing?
Thank you in advance for your help.
Best regards,
Giovanni