What does this Exception mean?
Aspose.Cells.CellsException: Invalid ValidationAlertType string val
at ee.Warning(WarningInfo )
at .()
at .(Workbook , LoadOptions , Boolean )
at .(Stream )
at .(String , Stream , LoadOptions )
at Aspose.Cells.Workbook.(String , LoadOptions )
at Aspose.Cells.Workbook…ctor(String file, LoadOptions loadOptions)
Cause
The Aspose.Cells.CellsException: Invalid ValidationAlertType string val error typically occurs when there is an issue with the data validation settings in your Excel file. This can happen if the validation alert type specified in the file is not recognized or is invalid.
Solution
To resolve this issue, you should check the data validation settings in your workbook. Ensure that the ValidationAlertType you are using is valid and matches one of the predefined types in Aspose.Cells. The valid alert types include:
ValidationAlertType.STOPValidationAlertType.WARNINGValidationAlertType.INFORMATION
Make sure that the alert type you are trying to set corresponds to one of these options.
Code
Here’s a sample code snippet that demonstrates how to set up data validation correctly:
using Aspose.Cells;
class Program
{
static void Main()
{
// Create a workbook
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
// Create a validation area
CellArea area = CellArea.CreateCellArea("A1", "A10");
ValidationCollection validations = worksheet.Validations;
// Add a validation
int index = validations.Add(area);
Validation validation = validations[index];
// Set validation type and properties
validation.Type = ValidationType.LIST;
validation.Formula1 = "Item1,Item2,Item3"; // Example list
validation.AlertStyle = ValidationAlertType.STOP; // Set a valid alert type
// Save the workbook
workbook.Save("DataValidationExample.xlsx");
}
}
Next Steps
- Review your existing validation settings to ensure they are using valid alert types.
- If you are loading an existing workbook, check if it contains any invalid validation settings.
- Test the provided code snippet to see if it resolves the issue in a new workbook.
- If the problem persists, consider sharing the specific validation settings you are using for further assistance.
Please let me know if you need any more help!
But this exception occurs when I open an existing xlsx file, how to solve this problem?
@cnbjw
Would you like to provide sample file and runnable test code? Please compress the file and code into zip format and upload it here, we will check it soon.
I currently cannot provide the sample file because it belongs to my client and contains sensitive information. However, when I resave this file on my computer, the exception no longer occurs. I suspect that the client’s computer might be using a non-standard version of spreadsheet software, saving the file in a format incompatible with Aspose.Cells. I instructed the client to resave the problematic file using a more common version of the software. The issue has now been resolved.
@cnbjw
You can unzip xlsx file and check the dv node in sheetX.xml.
Error style of data validation must be information,warning ,stop.
We will simply ignore this exception if the value is not as above list.
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): CELLSNET-58744
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Thank you! I will check it.
We are pleased to inform you that your reported issue (Ticket ID: “CELLSNET-58744”) has been resolved. The fix/enhancement will be incorporated into the upcoming release of Aspose.Cells (v25.8), which is scheduled for the first half of August 2025. You will be notified when the new version is published.
The issues you have found earlier (filed as CELLSNET-58744) have been fixed in this update. This message was posted using Bugs notification tool by leoluo