问题
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