![](/img/trans.png)
[英]C# Is there a built-in function to convert a formatted String back to a Number?
[英]C# How to convert text formatted number with exclamation mark icon note to number formatted number?
更改單元格的數字格式不會執行任何操作,因為它只會影響數字值的直觀表示,並且值是字符串,而不是數字。
您將需要將數字從字符串轉換為兼容的數字類型double
或int
具體取決於內容,甚至可能是Decimal
並將字符串值替換為轉換后的數字。
像這樣(未經測試)可能會這樣做:
foreach (var cell in range.Cells)
{
double value;
if (double.TryParse(cell.Value.ToString(), out value))
cell.Value = value;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.