我想通过 Excel Interop 设置整列的 NumberFormat:
column.NumberFormat = "# ##0";
但是,Excel 添加了一个额外的斜杠(打开文档显示 #\##0
)。
我发现了以下相关问题:Excel interop adding slashes in my number formatting string
但是,使用 column.NumberFormatLocal
时,我遇到了一个异常:
Unhandled Exception: System.Runtime.InteropServices.COMException: Unable to set the NumberFormatLocal property of the Range class
有什么想法吗?
最佳答案
我可以通过使用 en-US 分隔符来解决问题:
column.NumberFormat = "#,##0"; // Note the comma
我不确定为什么。我的系统区域设置和我的应用程序的 CultureInfo
都是 de-AT
。我的系统千位分隔符也是 de-AT(即空格)。
出于某种原因,Excel Interop 仍然需要 en-US 分隔符。
关于c# - Excel Interop 将斜杠添加到 NumberFormat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35408328/