使用aspose单元格从另一个Excel中提取的Excel文件未打开

问题描述

我正在尝试使用aspose单元从excel文件提取ole对象。 尽管在所需位置成功提取了excel文件,但是提取文件未在excel中打开。 我在打开时收到此味精: Message I am getting when I open the extracted excel file

我也尝试过aspose-cells-20.3和20.8,但存在相同的问题。

用于提取excel文件代码是:

    private static void extractEmbeddedImages(Workbook workbook) throws Exception {
        // Get the OleObject Collection in the first worksheet.
        OleObjectCollection oles = workbook.getWorksheets().get(0).getoleObjects();
        PrintWriter ws=new PrintWriter(new File(sDataDir + "/" + sFileNameWithoutExt + "_EmbeddedFiles.txt"));
        //PrintWriter ws=new PrintWriter(new File(sDataDir + "/EmbeddedFiles.txt"));


        // 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).getUpperLeftColumn() < excludeColFrom) {
                if (oles.get(i).getMsoDrawingType() == MsoDrawingType.OLE_OBJECT) {
                    OleObject ole = (OleObject) oles.get(i);

                    String sRow=""+ole.getActualLowerRightRow();

                    com.aspose.cells.Cell cell  =  workbook.getWorksheets().get(0).getCells().getCell(Integer.parseInt(sRow),ole.getLowerRightColumn());
                    String sOrgFile=ole.getSourceFullName();

                    if(sOrgFile == null) //This code is only skipping those file with null resourceFullNme. 
                    {

                        if(ole.getProgID().equalsIgnoreCase("Bitmap Image"))
                            sOrgFile = ole.getLowerRightColumn()+ ".jpg";

                    }
                    else if(ole.getProgID().equalsIgnoreCase("Acrobat Document"))
                        sOrgFile = sOrgFile+".pdf";

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

                    sFnamme = sFnamme.substring(sFnamme.lastIndexOf("\\")+1);

                    boolean isExits=isAlreadyExits((Integer.valueOf(sRow)-1)+"_"+sFnamme);
                    if(isExits)
                        sFnamme=(Integer.valueOf(sRow)-4)+"_Temp_"+sFnamme;
                    else
                        sFnamme=(Integer.valueOf(sRow)-4)+"_"+sFnamme;

                    FileOutputStream fos;
                    try {
                        byte[] data = ole.getobjectData();
                        if(data != null) {
                            fos = new FileOutputStream(sDownloadDir + "/" +sFnamme);

                            try {
                                fos.write(data);
                            } catch (IOException e1) {
                                // Todo Auto-generated catch block
                                e1.printstacktrace();
                            }
                            try {
                                fos.close();
                                ws.println(sFnamme);

                            } catch (IOException e) {
                                // Todo Auto-generated catch block
                                e.printstacktrace();
                            }
                        }
                    } catch (FileNotFoundException e) {
                        // Todo Auto-generated catch block
                        e.printstacktrace();
                    }
                }
            }
        }
        ws.close();
    }

请帮助。

预先感谢

-Swapnil

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...