翻譯|使用教程|編輯:李顯亮|2020-01-19 09:47:48.013|閱讀 426 次
概述:在本系列教程中,將為開發者帶來Aspose.Cells for .NET的一系列使用教程,例如關于加載保存轉換、字體、渲染、繪圖、智能標記等等。本文將講解如何將數字簽名添加到已經簽名的Excel文件中。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Aspose.Cells for .NET是Excel電子表格編程API,可加快電子表格管理和處理任務,支持構建具有生成,修改,轉換,呈現和打印電子表格功能的跨平臺應用程序。
在接下來的系列教程中,將為開發者帶來Aspose.Cells for .NET的一系列使用教程,例如關于加載保存轉換、字體、渲染、繪圖、智能標記等等。本文將講解如何將數字簽名添加到已經簽名的Excel文件中。
Aspose.Cells提供了Workbook.AddDigitalSignature(DigitalSignatureCollection digitalSignatureCollection) 方法,可用于將數字簽名添加到已簽名的Excel文件中。
注意:在將數字簽名添加到已經簽名的Excel文檔時,請注意,如果原始文檔是Aspose.Cells生成的文檔,則可以正常工作。但是,如果原始文檔是由其他引擎(例如Microsoft Excel等)生成的,則Aspose.Cells無法在加載并重新保存文件后使文件保持不變,這將使原始簽名無效。
下面的示例代碼演示了如何利用 Workbook.AddDigitalSignature(DigitalSignatureCollection digitalSignatureCollection) 方法將數字簽名添加到已簽名的Excel文件中。請檢查此代碼中使用的示例Excel文件。該文件已經過數字簽名。屏幕截圖顯示了執行后示例代碼對示例Excel文件的影響。
//Certificate file and its password string certFileName = sourceDir + "AsposeDemo.pfx"; string password = "aspose"; //Load the workbook which is already digitally signed to add new digital signature Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook(sourceDir + "sampleDigitallySignedByCells.xlsx"); //Create the digital signature collection Aspose.Cells.DigitalSignatures.DigitalSignatureCollection dsCollection = new Aspose.Cells.DigitalSignatures.DigitalSignatureCollection(); //Create new certificate System.Security.Cryptography.X509Certificates.X509Certificate2 certificate = new System.Security.Cryptography.X509Certificates.X509Certificate2(certFileName, password); //Create new digital signature and add it in digital signature collection Aspose.Cells.DigitalSignatures.DigitalSignature signature = new Aspose.Cells.DigitalSignatures.DigitalSignature(certificate, "Aspose.Cells added new digital signature in existing digitally signed workbook.", DateTime.Now); dsCollection.Add(signature); //Add digital signature collection inside the workbook workbook.AddDigitalSignature(dsCollection); //Save the workbook and dispose it. workbook.Save(outputDir + "outputDigitallySignedByCells.xlsx"); workbook.Dispose();
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn