共有ワークブックのパスワード保護または解除をC++で行う
Contents
[
Hide
]
可能な使用シナリオ
以下のスクリーンショットに示すように、Microsoft Excelで共有ブックを保護または保護解除することができます。Aspose.Cellsでも、Workbook::ProtectSharedWorkbook()メソッドとWorkbook::UnprotectSharedWorkbook()メソッドを使用することでこの機能をサポートしています。
共有ワークブックのパスワード保護または保護解除
次のサンプルコードは、ブックを作成し、共有を有効にした状態で保護し、出力Excelファイルとして保存します。スクリーンショットに示すように、保護を解除しようとすると、Microsoft Excelがパスワードの入力を要求します。
サンプルコード
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Create empty Excel file
Workbook wb;
// Protect the Shared Workbook with Password
wb.ProtectSharedWorkbook(u"1234");
// Uncomment this line to Unprotect the Shared Workbook
// wb.UnprotectSharedWorkbook(u"1234");
// Save the output Excel file
wb.Save(u"outputProtectSharedWorkbook.xlsx");
std::cout << "Shared workbook protection applied successfully!" << std::endl;
Aspose::Cells::Cleanup();
}