问题描述
range.NumberFormat =_ R *### 0_;;
其中范围
的类型为 Microsoft.Office.Interop.Excel.Range
然而,当我打开电子表格并通过选择自定义格式检查格式化字符串字符串现在看起来像这样:
_ \R *#\ ## 0_;
这些添加的斜杠意味着只有一千个分隔符(一个空格)存在,其余的
我也尝试过:
range .NumberFormat = @_ R *### 0_;;
我尝试过MSDN,但是这个标语文档对我来说就像是乱七八糟:
但它做同样的事情。任何人都知道如何防止这种情况发生?
设置 NumberFormatLocal
属性似乎已经为我解决了:
range.NumberFormatLocal =_ R *### 0_;;
不知道为什么虽然...很高兴接受一个更完整的答案,解释为什么有一个问题,为什么这会修复它。
I'm trying to set a number format (South African Rand currency, no decimals) to a range like so:
range.NumberFormat = "_ R * # ##0_;";
where range
is of type Microsoft.Office.Interop.Excel.Range
however when I open the spreadsheet and check the formatting string by choosing custom format the string now looks like this:
_ \R * #\ ##0_;
and these added slashes means that only the first thousand separator (a space) is present and the rest are left off.
I've also tried this:
range.NumberFormat = @"_ R * # ##0_;";
I tried MSDN but this paricular doc reads like gibberish to me: http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel.range.numberformat.aspx
but it does the same thing. Anyone know how to prevent this from happening?
Setting NumberFormatLocal
property seems to have solved it for me:
range.NumberFormatLocal = "_ R * # ##0_;";
No idea why though... and happy to accept a more complete answer that explains why there is a problem and why this fixes it.
这篇关于Excel interop在我的数字格式化字符串中添加斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!