Aspose.Cells opens OLE objects

Hi,

In some cases I use Aspose.Cells to determine whether compound file is actually Excel file. So I try to open file:

var w = new Aspose.Cells.Workbook(doc.FilePath, new Aspose.Cells.LoadOptions() { Password = doc.PassOpen });

I found that Aspose.Cells opens OLE packages which are not Excel files. I attached ZIP with those files. All of them are objects from Outlook messages in rich-text format (PR_ATTACH_METHOD is ATTACH_OLE): signature images, Equation 3.0 and others.

I use Aspose.Cells 7.6.1.0.

Hi,


Please try our latest version/fix: Aspose.Cells for .NET v7.7.2:

I think you may use CellsHelper or FileFormatUtil static methods to detect the file formatting type for your needs. I used your files to detect the file formats, it gives me Unknown which is correct.
e.g
Sample code:
string filePath = @“E:\test2\oleobjects\3kfl4qov.g0j”;
FileFormatType fmt = CellsHelper.DetectFileFormat(filePath);

//Detect file format
Debug.WriteLine("File Format: " + fmt.ToString()); //Unknown


Thank you.

Thank you for quick response.

I tries with Aspose.Cells 7.7.2.0. It says that CellsHelper.DetectFileFormat method does not exist (in earlier version it was marked as “obsolete”). So I used Aspose.Cells.FileFormatUtil.DetectFileFormat instead.

And it seems that I cannot rely on Aspose.Cells.DetectFileFormat. It works well with files I attached earlier, but returns incorrect value in following cases:

  1. “Excel2007Xlsx” for password protected DOCM/DOCX/DOTM/DOTX;
  2. “Excel2007Xlsx” for password protected POTM/POTX/PPTM/PPTX.

You may suggest using Aspose.Cells.DetectFileFormat in conjunction with Aspose.Words.FileFormatUtil.DetectFileFormat (14.1.0.0), but it also has problems:

  1. Returns “Docx” for password protected POTM/POTX/PPTM/PPTX
  2. Returns “Docx” for password protected XLSX/XLSM/XLSB/XLTM/XLTX

Because of these problems I chose loading files like in my first and catching Exceptions like

  • Aspose.Words.UnsupportedFileFormatException
  • Aspose.Slides.PptCorruptFileException
  • Aspose.Slides.Pptx.PptxCorruptFileException
  • Etc.

Best regards,

Alex Shloma

Hi Alex,


Yes, CellsHelper.DetectFileFormat is obsoleted and you may use FileFormatUtil.DetectFileFormat API instead, see the document for your reference:
http://www.aspose.com/docs/display/cellsnet/How+to+Detect+a+File+Format+and+Check+if+the+File+is+Encrypted

Could you elaborate more and for the file formats you attached, do you need Aspose.Cells should throw some sort of Exception when loading the file? we may look into it as well.


Also, for your issue(s) with detecting files e.g DOCx, DOTx, POTx, PPTx and other Excel file, please try using the latest version, if you still find the issue, kindly create a separate thread(s) with attachments and sample code to show the issue, we will check it soon.

Thank you.


Could you elaborate more and for the file formats you attached, do you need Aspose.Cells should throw some sort of Exception when loading the file? we may look into it as well.

Yes, it would be good if Aspose.Cells.Workbook(path) threw Aspose.Cells.CellsException with Code property set to Aspose.Cells.ExceptionType.FileFormat, when I try to open OLE packages like I attached in the first post.

Also, for your issue(s) with detecting files e.g DOCx, DOTx, POTx, PPTx and other Excel file, please try using the latest version…

I tested on the latest Cells and Words – 7.7.2.0 and 14.1.0.0 accordingly.

… if you still find the issue, kindly create a separate thread(s) with attachments and sample code to show the issue, we will check it soon.

Will do it for Aspose.Words.FileFormatUtil.DetectFileFormat and Aspose.Cells.FileFormatUtil.DetectFileFormat.

Thank you,

Alex Shloma

Hi,


Thanks for providing further details.

As we have observed the issue as you mentioned. We will check if it is feasible to throw an exception when opening/loading non native MS Excel files as you have provided the files archive. I have logged a ticket with an id “CELLSNET-42396” for your issue. We will look into your issue soon.

Once we have any update on it, we will let you know here.

Thank you.