Swapnil Hadge
Swapnil Hadge

Reputation: 57

How to get file name with extension from oleObject of Excel file using aspose?

I am trying to get the file name of the ole object from excel file using aspose cells. For majority of files I am able to get it using getSourceFullName(). I even tried other methods related to file name. In specific cases, I get null for getSourceFullName(); but the binary data is still there and I can create a file for it if I know the extn.

This is my code snippet:

// Loop through all the ole objects and extract each object. in the worksheet.
        for (int i = 0; i < oles.getCount(); i++) {
            if (oles.get(i).getMsoDrawingType() == MsoDrawingType.OLE_OBJECT) {
                OleObject ole = (OleObject) oles.get(i);

                String sRow=""+ole.getActualLowerRightRow();
                //Cell cells = workbook.getWorksheets().get(0).getCells().getCell(ole.getActualLowerRightRow(), 26);
                //System.out.println(ole.getPlacement());
                //System.out.println(ole.getLinkedCell());
                String sOrgFile=ole.getSourceFullName();

                //System.out.println(   ole.getZOrderPosition());
                //System.out.println(ole.getId());
                if(sOrgFile == null) //This code is only skipping those file with null resourceFullNme. 
                {
                    continue;//this is to handle the issue that resoirceFull name is NULL for certain embedded file.
                }


                String sFnamme= new File(sOrgFile).getName();

I get every other information except file name. Can someone please help me through this?

Thanks in advance. -Swapnil

Upvotes: 0

Views: 645

Answers (0)

Related Questions