Adding ole objects in a pre-existing workbook does not work in .NET

My company is evaluating this product and while doing some testing we found this case
var workbook = new Workbook();
workbook.Worksheets[0].Name = "wksheet0";
for (var index = 1; index < 2; ++index)
{
workbook.Worksheets.Add("wksheet" + index);
}
for (var index = 0; index < workbook.Worksheets.Count; ++index)
{
var worksheet = workbook.Worksheets[index];
addChart(1, 1, 600, 600, worksheet);//just adds an olebject with image data and oleobject data
System.Console.WriteLine("Adding chart for worksheet[" + index + "]");
}
workbook.Save(dataDir + "oneChartPerWorksheet.xlsx", SaveFormat.Xlsx);
workbook = new Workbook(dataDir + "oneChartPerWorksheet.xlsx", loadOptions);
for (var index = 0; index < workbook.Worksheets.Count; ++index)
{
var worksheet = workbook.Worksheets[index];
addChart(1, 16, 600, 600, worksheet);
System.Console.WriteLine("Adding chart for worksheet[" + index + "]");
}
workbook.Save(dataDir + "twoChartsPerWorksheet.xlsx", SaveFormat.Xlsx);
The first worksheet contains two charts (image + oleobject) but the second worksheet just contains images.
I have installed the latest build of Aspose.


Hi Daniel,

Thanks for your posting and considering Aspose.Cells.

Please provide us your runnable sample console application project that is replicating this issue with the latest version: Aspose.Cells for .NET 8.3.0.

We will investigate this issue and execute your project at our end. If it is a bug, we will log it in our database so that this issue could be fixed at the earliest.

Thanks for your cooperation.

Attached you can see a sample project. I am using the latest version of Aspose.

Hi Daniel,

Thanks for your posting and considering Aspose.Cells.

In order to investigate this issue further, please provide us an Excel file which you should create manually using Microsoft Excel with your embedded OLE object and post it here.

It will help us look into this issue more closely and precisely and we will be able to provide you a sample code how to achieve your desired results. In case, it is a bug, we will log it in our database so that it could be fixed at the earliest.

Attached you can find the visual studio project. I have created a workbook with Excel 2013 which contains 3 worksheets and each worksheet contains 1 chart.

After I run the sample project which inserts one chart on each worksheet the last worksheet just contains 2 pictures.
Let me know if you have any questions.

Hi Daniel,

Thanks for your posting and considering Aspose.Cells.

We were able to observe this issue after executing the following code with the latest version: Aspose.Cells for .NET 8.3.0. The ole objects in new workbook were inserted correctly. However, the ole objects in the existing workbook were inserted correct in sheet1 and sheet2 but in sheet3, ole objects were converted into pictures. The ole object that was already present was also converted into picture while the new ole object that was inserted using Aspose.Cells were also converted into picture.

We have logged this issue in our database for investigation. We will look into it and fix this issue. Once, the issue is resolved or we have some other update for you, we will let you know asap.

This issue has been logged as

  • CELLSNET-43182 - Ole objects in last worksheet are converted into pictures

I have also attached the output Excel files generated by the code and screenshot highlighting this issue for a reference.

C#

static void addChart(int upperLeftRow, int upperLeftColumn, int height, int width, Worksheet worksheet)

{

byte[] imageBytes, oleObjectBytes;

var imageDataFilePath = “F:/Shak-Data-RW/Downloads/Aspose/Aspose/Data/imagedata.txt”;

imageBytes = System.IO.File.ReadAllBytes(imageDataFilePath);

var oleObjectDataFilePath = “F:/Shak-Data-RW/Downloads/Aspose/Aspose/Data/oleobjectdata.txt”;

oleObjectBytes = System.IO.File.ReadAllBytes(oleObjectDataFilePath);

var index = worksheet.OleObjects.Add(upperLeftRow, upperLeftColumn, height, width, imageBytes);

worksheet.OleObjects[index].ObjectData = oleObjectBytes;

}


void Run()

{

var dataDir = Path.GetFullPath(@"F:\Shak-Data-RW\Downloads\Aspose\Aspose\Data");

var outputDir = dataDir + “output/”;

var workbook = new Workbook();

workbook.Worksheets[0].Name = “wksheet0”;

for (var index = 1; index < 2; ++index)

{

workbook.Worksheets.Add(“wksheet” + index);

}

for (var index = 0; index < workbook.Worksheets.Count; ++index)

{

var worksheet = workbook.Worksheets[index];

addChart(1, 1, 600, 600, worksheet);

System.Console.WriteLine(“Adding chart for worksheet[” + index + “]”);

}

workbook.Save(outputDir + “OleObjectsInNewWorkbookWereInsertedCorrectly.xlsx”, SaveFormat.Xlsx);


var loadOptions = new LoadOptions(LoadFormat.Xlsx);

workbook = new Workbook(outputDir + “Book1.xlsx”, loadOptions);

for (var index = 0; index < workbook.Worksheets.Count; ++index)

{

var worksheet = workbook.Worksheets[index];

addChart(1, 16, 600, 600, worksheet);

System.Console.WriteLine(“Adding chart for worksheet[” + index + “]”);

}

//last worksheet only contains pictures not the oleobject

workbook.Save(outputDir + “OleObjectsInLastWorksheetTurnedIntoPictures.xlsx”, SaveFormat.Xlsx);

}

Hi,

Thanks for your using Aspose.Cells.

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

I am afraid to say that v8.3.0.2 did not fix the issue. I ran my sample project and I still see the same behavior. Sheet3 contains only 2 pictures, the oleobject is missing.

Can you confirm that you see the same behaviour with the sample project i attached to this reply?
Thank you.

Hi,

Thanks for your feedback and using Aspose.Cells.

We were able to observe this issue with the latest version and found the issue is not fixed. We will look into it and provide you a fix within next few days.

Hi,

Thanks for your using Aspose.Cells.

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

Great job. Confirming that the bug is fixed.

Thanks for the quick turn around.
D

Hi Daniel,

Thanks for your feedback and considering Aspose.Cells.

It is good to know that your issue is resolved with the latest version. Let us know if you encounter any other issue, we will be glad to look into it and help you further.

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


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