الحصول على التحقق المطبق على خلية ما
Contents
[
Hide
]
يمكنك استخدام Aspose.Cells for JavaScript عبر C++ للحصول على التحقق المطبق على خلية. يوفر Aspose.Cells طريقة Cell.validation لهذا الغرض. إذا لم يكن هناك تحقق مطبق على الخلية، فإنه يعيد null.
بالمثل، يمكنك استخدام الأسلوب Worksheet.validations.validationInCell(number, number) للحصول على التحقق المطبق على خلية عن طريق توفير مؤشرات الصف والعمود الخاصة بها.
كود جافا سكريبت للحصول على التحقق المطبق على خلية
يعرض لك رمز العينة التالي كيفية الحصول على التحقق المطبق على خلية.
<!DOCTYPE html>
<html>
<head>
<title>Aspose.Cells Example</title>
</head>
<body>
<h1>Read Validation Properties Example</h1>
<input type="file" id="fileInput" accept=".xls,.xlsx,.csv" />
<button id="runExample">Run Example</button>
<a id="downloadLink" style="display: none;">Download Result</a>
<div id="result"></div>
</body>
<script src="aspose.cells.js.min.js"></script>
<script type="text/javascript">
const { Workbook, SaveFormat, Utils } = AsposeCells;
AsposeCells.onReady({
license: "/lic/aspose.cells.enc",
fontPath: "/fonts/",
fontList: [
"arial.ttf",
"NotoSansSC-Regular.ttf"
]
}).then(() => {
console.log("Aspose.Cells initialized");
});
document.getElementById('runExample').addEventListener('click', async () => {
const fileInput = document.getElementById('fileInput');
if (!fileInput.files.length) {
document.getElementById('result').innerHTML = '<p style="color: red;">Please select an Excel file.</p>';
return;
}
const file = fileInput.files[0];
const arrayBuffer = await file.arrayBuffer();
// Instantiate the workbook from the selected Excel file
const workbook = new Workbook(new Uint8Array(arrayBuffer));
// Access its first worksheet
const worksheet = workbook.worksheets.get(0);
// Cell C1 has the Decimal Validation applied on it.
const cell = worksheet.cells.get("C1");
// Access the validation applied on this cell
const validation = cell.validation;
// Read various properties of the validation
let output = '';
output += '<p>Reading Properties of Validation</p>';
output += '<hr />';
output += `<p>Type: ${validation.type}</p>`;
output += `<p>Operator: ${validation.operator}</p>`;
output += `<p>Formula1: ${validation.formula1}</p>`;
output += `<p>Formula2: ${validation.formula2}</p>`;
output += `<p>Ignore blank: ${validation.ignoreBlank}</p>`;
document.getElementById('result').innerHTML = output;
});
</script>
</html>