I have purchased Apose Total Licence of version:
17.9.0.0
I have implemented functionality to embed attachments in Excel file.
However, I am not able to open the zip files and png files and jpeg files when embedding in Excel sheet. FOllowing code snippet is used.
I have tested your scenario/ case using the following sample code (please refer to it), it works fine and I can open the zipped archive when I clicked on the Ole object icon/image in Excel sheet in the output file. Please make sure that you have set the correct path for the zipped archive file or image file when using the “OleObject.ObjectSourceFullName”. Also, see the screenshot for your reference.
e.g Sample code:
Workbook workbook = new Workbook();
//Get the first worksheet.
Worksheet sheet = workbook.Worksheets[0];
//Define a string variable to store the image path.
string ImageUrl = "e:\\test\\school.jpg";
//Get the picture into the streams.
FileStream fs = File.OpenRead(ImageUrl);
//Define a byte array.
byte[] imageData = new Byte[fs.Length];
//Obtain the picture into the array of bytes from streams.
fs.Read(imageData, 0, imageData.Length);
//Close the stream.
fs.Close();
//Get zip file path in a variable.
string path = "e:\\test2\\Report90043.zip";
//Get the file into the streams.
fs = File.OpenRead(path);
//Define an array of bytes.
byte[] objectData = new Byte[fs.Length];
//Store the file from streams.
fs.Read(objectData, 0, objectData.Length);
//Close the stream.
fs.Close();
sheet.OleObjects.Add(0, 0, 40, 40, imageData);
//Set embedded ole object data.
sheet.OleObjects[0].ObjectData = objectData;
sheet.OleObjects[0].FileFormatType = FileFormatType.Unknown;
sheet.OleObjects[0].HeightInch = 0.64;
sheet.OleObjects[0].WidthInch = 0.78;
sheet.OleObjects[0].DisplayAsIcon = true;
sheet.OleObjects[0].ObjectSourceFullName = path;
//Save the excel file
workbook.Save("e:\\test2\\outMyFile12.xlsx");
I am using latest version/fix. Please try using latest version/fix and if you still find any issue with latest version (e.g Aspose.Cells for .NET v20.3.x), kindly do provide sample code (runnable) and sample file(s) to reproduce the issue, we will check it soon.
You may refer to Release notes section of different releases to know more about what is changed in the APIs for your reference:
There is nothing special for upgrading to latest version. You may use the newer Aspose.Cells.Dll (adding reference to it and replacing/removing older version in your project), see the document for your reference:
PS. Your current subscription might be expired to use latest versions of Aspose.Cells, so, you would also need to upgrade your subscription as well.
ok…
Your current subscription might be expired to use latest versions of Aspose.Cells, so, you would also need to upgrade your subscription as well. How to change the subscription?