Reputation: 61
I'm having troubles setting columns format in Excel with Interop. I'm using C#, below is the code:
Excelop.Range rg = (Excelop.Range)wb.Worksheets[1].Cells[1, i];
rg.NumberFormat = "@"; //Exception is raised here
I get the below exception when compiled:
"An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll
Additional information: Unable to set the NumberFormat property of the Range class"
Appreciate your support.
Upvotes: 0
Views: 739
Reputation: 23975
My guess is that your worksheet is protected.
You likely need to do something like:
wb.Worksheets[1].Unprotect (Password:"your_password")
These may be of assistance:
"Unable to set the NumberFormat property of the Range class"
Upvotes: 0