Methods to get validation limits instead of an exception

Hi,


We got the following Exception:
java.lang.IllegalArgumentException: Too many CellAreas for validation, maximum count of CellArea for this Validation is 1021
at com.aspose.cells.Validations.a(Unknown Source)
at com.aspose.cells.L.q(Unknown Source)
at com.aspose.cells.L.a(Unknown Source)
at com.aspose.cells.dL.x(Unknown Source)
at com.aspose.cells.dL.a(Unknown Source)
at com.aspose.cells.Workbook.save(Unknown Source)

Is it possible to ask the Aspose Cells Api about the limits before getting a runtime exception?  Are the limits constant?  If not, maybe you could provide methods that calculate the limits?
Thanks & Best regards
Ulf Ekström

Hi,

Well, actually it is not a fixed value/number for it. It is, in fact a value that is calculated by the Saving process when saving the workbook. One validation’s record cannot exceed its maximum length, this record contains the settings of validation, such as, the condition, the error messages, and so on, etc. So, if there are many settings implemented for the validation, such as, the length of error message i.e., the longer it is, the lesser would be the count of the areas (contained), because more space in this record will be needed by the error message. It is the limit put forth by Excel 2003 actually.

Thank you.

Thanks for your quick reply. Does this mean that the limits are different depending on which type of Excel version we are exporting to?


Best Regards,
Ulf

Hi Ulf,

Yes, it is mainly limited by excel97-2003 file format. If you save the workbook as excel2007 file format, there will be no such limit.

Thanks,

Ok, thanks.


Best Regards,
Ulf

Hi,


Can you please create a specific exception for this, like TooManyCellAreasException instead of throwing an IllegalArgumentException? That way we can catch it and take appropriate action.

Thanks,
Ulf

Hi Ulf,

For this exception, how about replacing it by a CellsException with code “INTERNAL_CHECK_ERROR”? If it can fit your requirement, we will provide a fix soon.

That will be perfect. Thanks!


Best Regards,
Ulf

Hi,

Please try the attached version.

Now we will give CellsException with code like “INTERNAL_CHECK_ERROR” when the Validation contains too much areas.


Thank you.

Thanks for the quick fix.


Best regards,
Ulf