Bir Dosya Biçimini Algılamak ve Dosyanın Şifreli Olup Olmadığını Kontrol Etme
Contents
[
Hide
]
Bazen, dosyanın içeriğinin uygun olup olmadığını garanti etmeyen dosya uzantısına sahip olmasından dolayı, bir dosya açmadan önce biçimini tespit etmeniz gerekir. Dosya şifrelenmiş olabilir (şifre korumalı bir dosya) ya da doğrudan okunmamalıdır. Aspose.Cells for Python via .NET, FileFormatUtil.detect_file_format() statik metodunu ve belge işlemede kullanabileceğiniz bazı ilgili API’leri sağlar.
Aşağıdaki örnek kod, dosya biçimini (dosya yolu kullanarak) algılamanın ve uzantısını kontrol etmenin nasıl yapıldığını göstermektedir. Ayrıca dosyanın şifreli olup olmadığını belirleyebilirsiniz.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |