Click here to Skip to main content
14,735,205 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

how to add the validation to the excel sheet..
the validation is, it is the input field it allows only 2 digits after a decimal points please help me soon....
like 2.33

Posted
Comments
Kiran Susarla 1-Jan-13 23:54pm
   
Are you using excel COM Interop libraries or OpenXML?
Member 9644686 1-Jan-13 23:57pm
   
excel COM Interop library,.....

1 solution

1. You need get the Range for which you want to add the validation.
//Select the specified cell
Range cell = worksheet.Cells[row, column];

2. Once you get the Range, you can call the Validation.Add method on the Range object.
//Delete any previous validation
cell.Validation.Delete();
//Add the validation, that only allowes selection of provided values.
cell.Validation.Add(<<pass the required parameters>>)


More information about the Validation methods and properties is available at
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.validation.add(office.11).aspx[^]
   
Comments
Member 9644686 2-Jan-13 2:57am
   
will u tell what can i pass as parameter please send me detail snippets please
Kiran Susarla 2-Jan-13 3:32am
   
Please go through the MSDN link that I have shared. That link has the details of all the parameters that can be passed.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900