Detecting file format

Aspose.Words has a DetectFileFormat method that will return the type of document I am working with. Does Aspose.Cells have an equivalent method? I noticed that it does have a similar format enum.

My issue is that my code needs to be able to handle files of different types. Therefore, my first step is to determine what type of file (Words or Cells, for instance) I am dealing with so I know how to handle it. For Aspose.Words, I am using DetectFileFormat and checking the resulting LoadFormat enum. If I get back "Unknown", I want to check if it fits under Cells.

What is the best method for doing this?

Thanks,

Todd

Hi Todd,

I think you can use the suffix to determine the file type.

Workbook.Open method can automatically detect if it's an Excel file. It will throw an exception if it isn't.

If you mean the extension, I would rather avoid that since their is no guarantee that their will be an extension and that it is correct. I was hoping that their was a function like the one found in Aspose.Words. I assume, from your statement, that there is not.

In that case i'll just have to try and open it and catch the exception.

Thanks,

Todd