[英]Decimal separator comma but I want save data with point
I have to read and write an excel file. 我必须读写Excel文件。 The problem is that when a PC is the decimal separator, (comma) also in the excel file numbers with the comma will be saved.
问题是,当PC是小数点分隔符时,也会在excel文件编号中保存带逗号的(逗号)。 I would like to save the values for all modes with the point instead of a comma.
我想用点而不是逗号保存所有模式的值。
Here is a piece of code: 这是一段代码:
var wb = openWorkBook(filename);
var ws = wb.Worksheet("CNF");
IXLRow row = ws.Row(device.Ordinal - 1 + FirstRow);
for (int j = 0; j < MAXCOLS; ++j)
{
IXLCell cell = row.Cell(j + FirstCol);
cell.Value = Convert.ChangeType(device[j], m_column_type[j]);
}
Convert.ChangeType(object, Type)
uses the thread's current culture for conversion. Convert.ChangeType(object, Type)
使用线程的当前区域性进行转换。 It sounds like you want the invariant culture, so you should use Convert.ChangeType(object, Type, IFormatProvider)
: 听起来像您想要不变的文化,所以您应该使用
Convert.ChangeType(object, Type, IFormatProvider)
:
cell.Value = Convert.ChangeType(device[j], m_column_type[j],
CultureInfo.InvariantCulture);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.