行と列の保護
このトピックでは、開発者が行や列のセルをエンドユーザーによるアクションから保護するためのいくつかのテクニックについて説明します。セルを読み取り専用にすることで、削除を防ぐことができます。また、Aspose.Cells.GridWebのコンテキストメニューオプションを制限することで保護を実装することができます。これらのテクニックについては、例を使用して以下で詳しく説明します。
行と列のセルを保護する
行と列を読み取り専用にする
ワークシートの行や列を保護する方法の一つは、セルを読み取り専用にすることです。そのため、エンドユーザーがそれらを削除することはできません。
行や列を読み取り専用にするには:
Web フォームに Aspose.Cells.GridWeb コントロールを追加します。
コレクション内の GridWorksheet にアクセスします。
行または列のセルを読み取り専用に設定します。
This file contains 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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Accessing the first worksheet that is currently active
GridWorksheet sheet = GridWeb1.WorkSheets[GridWeb1.ActiveSheetIndex];
// Set the 1st cell (A1) read only
sheet.SetIsReadonly(sheet.Cells["A1"], true);
コンテキストメニューオプションの制限
Aspose.Cells.GridWeb は、ユーザーがコントロール上で操作を実行するために使用できるコンテキストメニューを提供します。このメニューには、セル、行、および列を操作するための多くのオプションが用意されています。
完全なコンテキストオプション
コンテキストメニューで利用可能なオプションを制限することで、行や列に対するクライアント側の操作を制限することが可能です。これは、GridWeb コントロールの EnableClientColumnOperations および EnableClientRowOperations プロパティを false に設定することで行うことができます。また、GridWeb コントロールの EnableClientFreeze プロパティを false に設定することで、ユーザーが行や列を固定することを制限することも可能です。
行と列のオプションを制限した後のコンテキストメニュー
This file contains 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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
// Restricting column related operations in context menu
GridWeb1.EnableClientColumnOperations = false;
// Restricting row related operations in context menu
GridWeb1.EnableClientRowOperations = false;
// Restricting freeze option of context menu
GridWeb1.EnableClientFreeze = false;