开发者

C# Converting a Percentage Value read from Excel to a Double

开发者 https://www.devze.com 2023-03-22 15:09 出处:网络
I am reading a percentage value from an excel file, and I need this value to be of type double. I am using xlWorkSheet.get_Range(\"A1\", \"A1\")Value2 to retrieve the value. Casting / converting to a

I am reading a percentage value from an excel file, and I need this value to be of type double.

I am using xlWorkSheet.get_Range("A1", "A1")Value2 to retrieve the value. Casting / converting to a double isn't working.

开发者_运维知识库

How can I convert this percentage to a double?


If your input is 87.5%, you'll need to get rid of the % sign first:

var inputText = "87.5%";
var doubleValue = Double.Parse(inputText.Replace("%", ""));
0

精彩评论

暂无评论...
验证码 换一张
取 消