Aspose.Cells を使用して変更するパスワードを確認してください

Microsoft Excel で変更するパスワードを確認してください

割り当てることができます開くためのパスワード変更するパスワードMicrosoft Excel でワークブックを作成している間。これらのパスワードを指定するために Excel が提供するインターフェース Microsoft を示すこのスクリーンショットを参照してください。

todo:画像_代替_文章

Aspose.Cells を使用して変更するパスワードを確認してください

次のサンプル コードは、ソースエクセルファイル。 1234 として開くパスワードと 5678 として変更するパスワードがあります。コードは最初に 567 が変更する正しいパスワードであるかどうかを確認し、false を返し、次に 5678 が変更するパスワードであるかどうかを確認し、true を返します。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Specify password to open inside the load options
LoadOptions opts = new LoadOptions();
opts.Password = "1234";
// Open the source Excel file with load options
Workbook workbook = new Workbook(dataDir + "sampleBook.xlsx", opts);
// Check if 567 is Password to modify
bool ret = workbook.Settings.WriteProtection.ValidatePassword("567");
Console.WriteLine("Is 567 correct Password to modify: " + ret);
// Check if 5679 is Password to modify
ret = workbook.Settings.WriteProtection.ValidatePassword("5678");
Console.WriteLine("Is 5678 correct Password to modify: " + ret);

コンソール出力

上記のサンプル コードをロードした後のコンソール出力は次のとおりです。ソースエクセルファイル。

Is 567 correct Password to modify: False

Is 5678 correct Password to modify: True