Cell データ検証を追加
Contents
[
Hide
]
Aspose.Cells.GridWeb を使用すると、追加できますデータ検証GridWorksheet.Validations.Add() メソッドを使用します。このメソッドを使用して、指定する必要がありますCell 範囲.ただし、単一の GridCell でデータ検証を作成する場合は、GridCell.CreateValidation() メソッドを使用して直接行うことができます。同様に、あなたは削除することができますデータ検証GridCell.RemoveValidation() メソッドを使用して GridCell から。
GridWeb の GridCell でデータ検証を作成する
次のサンプル コードは、データ検証セル B3 に20 ~ 40 以外の値を入力すると、セル B3 が表示されます。検証エラーの形で赤XXXXこのスクリーンショットに示すように。
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 | |
// Access first worksheet | |
GridWorksheet sheet = GridWeb1.WorkSheets[0]; | |
// Access cell B3 | |
GridCell cell = sheet.Cells["B3"]; | |
// Add validation inside the gridcell | |
// Any value which is not between 20 and 40 will cause error in a gridcell | |
GridValidation val = cell.CreateValidation(GridValidationType.WholeNumber, true); | |
val.Formula1 = "=20"; | |
val.Formula2 = "=40"; | |
val.Operator = GridOperatorType.Between; | |
val.ShowError = true; | |
val.ShowInput = true; |