Excel C#将单元格转换为百分比 [英] Excel c# convert cell to percentage

查看:455
本文介绍了Excel C#将单元格转换为百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将一个双精度格转换为一个百分比。
我在excel中使用了一个宏,它说:

I need to convert a cell with a double to a precentage. I used a macro in excel and it says:

Range("B5").Select
Selection.Style = "Percent"

当我在c#中执行此操作时,它不起作用:

When I do this in c#, it doesn't work:

Excel.Range procentRange = xlWorksheet.get_Range("A1","A1");
procentRange.Style = "Percent";

有人知道怎么做吗?

推荐答案

我已经在JN Web的帮助下找到了答案。

I've found the anwser with help of JN Web

Excel.Range procentRange = xlWorksheet.get_Range("A1","A1");    
procentRange.NumberFormat = "###,##%";

因此,首先需要一个范围,然后设置小数点并自动添加%-> 100时间乘法

So first you need a range, then set the decimals and add "%" -> automatically a 100 time multiplication

这篇关于Excel C#将单元格转换为百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆