We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.cells for java - problem with embedded files

Hi,

I want to use Aspose.cells for java (free trial for the moment) to test embed different types of files in excel (.pdf, .docx, .png, .jpeg, .txt, .xls, .xlsm …)
My excel result file can be .xls, .xlsx or .xlsm.

At first I test with .xls result file, and some embedded files seems to have problems.
When I click on embedded file .pdf, .docx, .xls, .xlsx, the embedded file is opened, but when I click on embedded file as .txt, .png, .jpeg, .xml, .html … there is an error message "Cannot start the source application for this object"

Is there a restriction on the possible type of embedded file in excel with Aspose.cells for java ?

Thanks

Hi Joëlle,


Thank you for considering Aspose APIs.

It would be of great help in understanding your presented scenario, and to pin point the problem cause if you can share an executable sample application along with supporting documents/files. We will evaluate it on our side to assist your further in this regard.

That said, please first give a try to the latest version of Aspose.Cells for Java 8.6.2.4 to see if you still can observe the mentioned behavior.

Hi Raza,
As you suggested, I tried with version Aspose-cells-8.6.2.4.jar, but I still have the same problem : if I embed a text file and then, try to open it (by click on the associated image), I have the following popup error : ‘Cannot start the source application for this object’.

Joëlle

Hi Joëlle,

Thanks for your feedback and reporting the bug nicely and using Aspose.Cells.

We have tested this issue with the following sample code using the latest version 8.6.2.4 and found the issue as described by you.

We have therefore 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

  • CELLSJAVA-41637 - Inserting Ole Objects cause popup error - Cannot start the source application for this object

I have also attached the source excel file used in this code, the output excel file generated by it as well as the image and text file used inside it. Also attached the screenshot showing the popup error for a reference.

**Java**

Workbook wb = new Workbook(“D:\Downloads\sample.xlsx”);

Worksheet ws = wb.getWorksheets().get(0);

String imgFile = “D:\Downloads\sample.png”;
String objFile = “D:\Downloads\sample.txt”;

File file = new File(imgFile);
byte[] binaryImg = new byte[(int)file.length()];
FileInputStream fis = new FileInputStream(file);
fis.read(binaryImg);

file = new File(objFile);
byte[] binaryObj = new byte[(int)file.length()];
fis = new FileInputStream(file);
fis.read(binaryObj);

int idx = ws.getOleObjects().add(4, 4, 200, 200, binaryImg);

OleObject o = ws.getOleObjects().get(idx);
o.setDisplayAsIcon(false);
o.setFileFormatType(FileFormatType.OLE_10_NATIVE);
o.setAutoSize(true);
o.setLink(false);
o.setObjectSourceFullName(“sample.txt”);
o.setProgID(“Packager Shell Object”);
o.setObjectData(binaryObj);

wb.save(“output.xlsx”);

**C#**

Workbook wb = new Workbook(“sample.xlsx”);

Worksheet ws = wb.Worksheets[0];

string imgFile = @“D:\Downloads\sample.png”;
string objFile = @“D:\Downloads\sample.txt”;

byte[] binaryImg = File.ReadAllBytes(imgFile);
byte[] binaryObj = File.ReadAllBytes(objFile);

int idx = ws.OleObjects.Add(4, 4, 200, 200, binaryImg);

OleObject o = ws.OleObjects[idx];
o.DisplayAsIcon = false;
o.FileFormatType = FileFormatType.Ole10Native;
o.IsAutoSize = true;
o.IsLink = false;
o.ObjectSourceFullName = “sample.txt”;
o.ProgID = “Packager Shell Object”;
o.ObjectData = binaryObj;

wb.Save(“output.xlsx”);

Hi,


This is to inform you that we have fixed your issue now. We will soon provide the fix after performing QA and incorporating other enhancements and fixes.

Thank you.

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


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

Hi,

I reproduce the problem with Aspose 8.6.3.
Error message ‘Cannot start the source application for this object’ is always present for embedded files as xxx.txt.


Hi Joelle,


I have tested this scenario against the latest version of Aspose.Cells for Java 8.6.3, and I am no longer able to replicate the said problem. In order to make sure that latest build of Aspose.Cells for Java is being referenced in your project, please display the Aspose.Cells for Java version on console using the CellsHelper.getVersion method. Below you can find my test code whereas sample spreadsheets along with one image and txt file are attached to this post for your reference.

Java
Workbook wb = new Workbook(dir + “book1.xlsx”);
Worksheet ws = wb.getWorksheets().get(0);

String imgFile = dir + “sample.png”;
String objFile = dir + “sample.txt”;

File file = new File(imgFile);
byte[] binaryImg = new byte[(int)file.length()];
FileInputStream fis = new FileInputStream(file);
fis.read(binaryImg);

file = new File(objFile);
byte[] binaryObj = new byte[(int)file.length()];
fis = new FileInputStream(file);
fis.read(binaryObj);

int idx = ws.getOleObjects().add(4, 4, 200, 200, binaryImg);

OleObject o = ws.getOleObjects().get(idx);
o.setDisplayAsIcon(false);
o.setFileFormatType(FileFormatType.OLE_10_NATIVE);
o.setAutoSize(true);
o.setLink(false);
o.setObjectSourceFullName(“sample.txt”);
o.setProgID(“Packager Shell Object”);
o.setObjectData(binaryObj);

wb.save(dir + “output.xlsx”);