How to Work with Validation in PHP
WorkbookValidator is a save-time structural check in Aspose.Cells FOSS for PHP — it is
not an Excel-style data-validation feature for cell input (dropdown lists or input
restrictions); the library’s API surface does not expose that kind of cell-level
validation.
Step-by-Step Guide
Step 1: Install the Package
git clone https://github.com/aspose-cells-foss/Aspose.Cells-FOSS-for-PHP.git
cd Aspose.Cells-FOSS-for-PHP
composer installStep 2: Import Required Classes
use Aspose\Cells_FOSS\Validation\ValidationMessageSeverity;Step 3: Save a Workbook (Validation Runs Automatically)
WorkbookValidator::ValidateForSave() runs internally as part of Workbook::Save() —
application code does not need to call it directly for normal use:
$workbook = new Workbook();
$sheet = $workbook->Worksheets[0];
$sheet->Cells['A1']->PutValue('Reviewed');
$workbook->Save('report.xlsx');Step 4: Recognize Validation Message Severities
Validation results are categorized by ValidationMessageSeverity:
echo ValidationMessageSeverity::Info() . PHP_EOL;
echo ValidationMessageSeverity::Warning() . PHP_EOL;
echo ValidationMessageSeverity::Error() . PHP_EOL;Frequently Asked Questions
Can I run WorkbookValidator myself before saving?
ValidateForSave() takes the library’s internal workbook and package model objects, so
it is intended to be invoked by Workbook::Save() itself rather than called directly
from application code.
Does the library support cell-level data validation (dropdown lists, input restrictions)?
No. WorkbookValidator validates the structure of the generated OpenXML package, not
end-user input on individual cells.