Skip to content

Restricting User entry in Excel

netspider

Asked Mar 5, 2008, 10:52 AM EST1 answer
Share
LinkedInX

Hi,

I have a C# application that writes data into Excel. I need to restrict one column to contain only numerical value.

In Excel, It should not allow the user to enter non-numerical values or should Prompt the user to enter only numerical values. I should achieve this functionality from C#  when I load values to Excel itself. This condition must be stored in Excel and should apply even after disconnecting from C# application.

Regards,
Meena

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0

    This can be acheived using Excel Range.Validation

    Sample:

    If I need to restrict the column to have only positive decimal values for column 4

    ((Excel.Range)xlWorksheet.Cells[3, 4]).EntireColumn.Validation.Add(Excel.XlDVType.xlValidateDecimal,Excel.XlDVAlertStyle.xlValidAlertStop, Excel.XlFormatConditionOperator.xlGreaterEqual, 0, 0);

    0