0

I've a workbook object in which I'm using excel formulas in certain cells. I'm programmtically setting the value for ProtectContents on IWorksheet object to turn the readonly mode on those cells on and off.

1.When the value of ProtectContents is set to true, I see that all the cells are in read-only mode as expected but the cell (which use excel formula) value show up as #NAME?.Is this how it works in Spreadsheetgear?

2.And when the ProtectContents is set back to false,I see all those cells which use formula still show value as as #NAME? but they are editable as expected.But wondering why are those cells values not getting evaluated??

Please advise.

Thanks for your help.

Vineet v
  • 175
  • 2
  • 13

1 Answers1

1

There should not be any correlation between #NAME? errors and the state of worksheet protection. #NAME? errors can occur for a number of reasons but without more details on your particular case it's impossible to say why you are seeing this.

One common reason you might see this in SpreadsheetGear (and I presume not in Excel itself?) is because the formulas in these problematic cells either directly or indirectly depend on a User Defined Function (UDF) in the VBA portion of your workbook, from an external XLL add-in, etc. SpreadsheetGear does not support executing UDFs via VBA or XLLs, so such functions would evaluate to #NAME?.

SpreadsheetGear does support implementing your own Custom Functions in your .NET application via the SpreadsheetGear.CustomFunctions.Function class and its Evaluate(...) method. If you discover the above being the cause, you could implement your own Function to make these cells correctly calculate. I'd provide sample code but I'm going out on a limb in the first place mentioning this as being the underlying cause. Update your question with more specifics and I can update mine accordingly if needed.

Tim Andersen
  • 3,014
  • 1
  • 15
  • 11