Excel interop adding slashes in my number formatting string

有些话、适合烂在心里 提交于 2019-12-14 03:14:42

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/26650219/excel-interop-adding-slashes-in-my-number-formatting-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!