Angewendete Validierung auf einer Zelle erhalten.
Sie können Aspose.Cells für Node.js verwenden, um die auf eine Zelle angewendete Validierung abzurufen. Aspose.Cells bietet dafür die Cell.getValidation()-Methode. Wenn keine Validierung auf die Zelle angewendet ist, gibt sie null zurück.
Ebenso können Sie die Worksheet.validations.getValidationInCell(number, number) Methode verwenden, um die auf eine Zelle angewendete Validierung durch Angabe ihrer Zeilen- und Spaltenindizes zu erhalten.
Node.js-Code zum Abrufen der auf eine Zelle angewendeten Validierung
Der folgende Code zeigt, wie Validierungen auf eine Zelle angewendet werden.
const AsposeCells = require("aspose.cells.node"); | |
const path = require("path"); | |
// The path to the documents directory. | |
const dataDir = path.join(__dirname, "data"); | |
// Instantiate the workbook from sample Excel file | |
const workbook = new AsposeCells.Workbook(dataDir + "sample.xlsx"); | |
// Access its first worksheet | |
const worksheet = workbook.getWorksheets().get(0); | |
// Cell C1 has the Decimal Validation applied on it. It can take only the values Between 10 and 20 | |
const cell = worksheet.getCells().get("C1"); | |
// Access the validation applied on this cell | |
const validation = cell.getValidation(); | |
// Read various properties of the validation | |
console.log("Reading Properties of Validation"); | |
console.log("--------------------------------"); | |
console.log("Type: " + validation.getType()); | |
console.log("Operator: " + validation.getOperator()); | |
console.log("Formula1: " + validation.getFormula1()); | |
console.log("Formula2: " + validation.getFormula2()); | |
console.log("Ignore blank: " + validation.getIgnoreBlank()); |