views:

207

answers:

2

Hello,

I generate some Excel file from an .NET C# application. I use PIA 2002.

I can password protect, do a freeze pane, change the color of the cells .... one thing I can't do. I'd like to allow for a specific range, the use can enter ONLY a number.....

How can I do this ?

Thanks,

A: 

Unfortunately there is no way to assign events per cells only on the whole worksheet. The only thing you can do is constantly check that range for values that are only numbers. This is relatively easy since you can get the values of the whole range in one shot into a double[][]

Stan R.
+1  A: 

I'm not sure of the controls available from C#, but Excel has a feature built in that would work in you can access it. The Data Validation feature allows you to control what entry is allowed in a cell. I would open Excel and play with the options, then see if you can reference in C#. I imagine you can if you can do all the other things you listed.

You'll want to choose to allow either 'whole number' or 'decimal' depending on your requirements.

guitarthrower