共有ワークブックのパスワード保護または解除をC++で行う

可能な使用シナリオ

以下のスクリーンショットに示すように、Microsoft Excelで共有ブックを保護または保護解除することができます。Aspose.Cellsでも、Workbook::ProtectSharedWorkbook()メソッドとWorkbook::UnprotectSharedWorkbook()メソッドを使用することでこの機能をサポートしています。

todo:image_alt_text

共有ワークブックのパスワード保護または保護解除

次のサンプルコードは、ブックを作成し、共有を有効にした状態で保護し、出力Excelファイルとして保存します。スクリーンショットに示すように、保護を解除しようとすると、Microsoft Excelがパスワードの入力を要求します。

todo:image_alt_text

サンプルコード

#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();
}