Prüfen, ob die digitale Signatur des VBA Codes gültig ist
Contents
[
Hide
]
Aspose.Cells für Python via .NET erlaubt es, zu überprüfen, ob die digitale Signatur des VBA-Codes gültig ist, mittels der Workbook.vba_project.is_valid_signed-Eigenschaft. Es gibt true zurück, wenn die Signatur gültig ist, ansonsten false. Die digitale Signatur des VBA-Codes wird ungültig, wenn Sie den VBA-Code ändern.
Überprüfen, ob die digitale Signatur von VBA-Code in Python gültig ist
Der folgende Code demonstriert die Verwendung dieser Eigenschaft anhand der Beispieldatei, die Sie über den bereitgestellten Link herunterladen können. Die gleiche Excel-Datei hat eine gültige Signatur, aber wenn wir ihren VBA-Code ändern und die Arbeitsmappe speichern, finden wir heraus, dass ihre Signatur ungültig geworden ist.
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 Workbook | |
# 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(".") | |
workbook = Workbook(dataDir + "sampleVBAProjectSigned.xlsm") | |
# Signature is valid | |
print("Is VBA Code Project Valid Signed: " + str(workbook.vba_project.is_valid_signed)) | |
# Modify the VBA Code, save the workbook then reload | |
# VBA Code Signature will now be invalid | |
code = workbook.vba_project.modules[1].codes | |
code = code.replace("Welcome to Aspose", "Welcome to Aspose.Cells") | |
workbook.vba_project.modules[1].codes = code | |
# Save | |
workbook.save(dataDir + "output_out.xlsm") | |
# Reload | |
workbook = Workbook(dataDir + "output_out.xlsm") | |
# Now the signature is invalid | |
print("Is VBA Code Project Valid Signed: " + str(workbook.vba_project.is_valid_signed)) |