Reputation: 180
My code:
columns = ws.get_Range("A:F", System.Type.Missing);
columns.NumberFormat = "@";
After I debug the program, there is green color flag beside my number cells.
Expectation:
Remove the green color flag after debugging.
What I investigated:
https://msdn.microsoft.com/en-us/library/office/ff195953.aspx
From the MSDN itself, it only showed VBA can ignore the error in the cells. But i not really believe that c# is unable to do it.
Upvotes: 3
Views: 3550
Reputation: 39
I'm using this code:
excelRange.Cells.Value = yourValue; // Must be set before the Ignore setting
excelRange.Cells.Errors[Excel.XlErrorChecks.xlNumberAsText].Ignore = true;
Upvotes: 1
Reputation: 87
Im using this, it will ignore and not show in Excel.
app.ErrorCheckingOptions.BackgroundChecking = false;
Upvotes: 0
Reputation: 4010
There is an object on the Application
called ErrorCheckingOptions
. You can change the NumberAsText
property from true
to false
.
Application.ErrorCheckingOptions.NumberAsText = false;
Note that this is a global (Application-level) option. I haven't tested, but it is likely that this option will persist across Excel instances (that is, once you close and reopen Excel).
Upvotes: 1