How to Detect a File Format and Check if the File is Encrypted

Contents
[ ]

The following sample code illustrates how to detect a file format (using the file path) and check its extension. You can also determine whether the file is encrypted.

from aspose.cells import FileFormatUtil
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# The path to the documents directory.
dataDir = RunExamples.GetDataDir(".")
# Detect file format
info = FileFormatUtil.detect_file_format(dataDir + "Book1.xlsx")
# Gets the detected load format
print("The spreadsheet format is: " + FileFormatUtil.load_format_to_extension(info.load_format))
# Check if the file is encrypted.
print("The file is encrypted: " + str(info.is_encrypted))