我有这个csv文件:
firstName;lastName;78
fn1;ln1;67
fn2;;56,7
fn3;ln3;23,5
fn4;ln4;16,7
这节课:
[DelimitedRecord(";")]
public partial class Person
{
private string firstName;
[FieldNullValue("default first name")]
private string lastName;
private string age;
public string FirstName
{
get { return firstName; }
set { firstName = value; }
}
public string LastName
{
get { return lastName; }
set { lastName = value; }
}
public string Age
{
get { return age; }
set { age = value; }
}
}
我使用此代码检索数据:
ExcelStorage provider = new ExcelStorage(typeof(Person));
provider.FileName = "data.csv";
System.Data.DataTable dataTable = provider.ExtractRecordsAsDT();
数据表包含:
dataTable.Rows[0].ItemArray
{object[3]}
[0]: "firstName;lastName;78"
[1]: "default first name"
[2]: {}
dataTable.Rows[1].ItemArray
{object[3]}
[0]: "fn1;ln1;67"
[1]: "default first name"
[2]: {}
dataTable.Rows[2].ItemArray
{object[3]}
[0]: "fn2;;56"
[1]: "7"
[2]: {}
dataTable.Rows[3].ItemArray
{object[3]}
[0]: "fn3;ln3;23"
[1]: "5"
[2]: {}
dataTable.Rows[4].ItemArray
{object[3]}
[0]: "fn4;ln4;16"
[1]: "7"
[2]: {}
我肯定错过了什么。
编辑:我将小数点分隔符从','替换为'。'我仍然得到同样糟糕的结果
答案 0 :(得分:1)
问题解决了:必须使用FileHelperEngine而不是ExcelStorage