csv文件里有个16位数字1203120200000001 但是我读出来的确实用科学记数法表示的,怎么能转换成普通的数字?谢谢 string fileName = FileUpload1.FileName;
string fPath = Server.MapPath("\\") + "CardFile\\";//上传到服务器的文件夹路径
if (Directory.Exists(fPath) == false)
{
Directory.CreateDirectory(fPath);
}
string filePath = fPath + fileName;//绝对路径
FileUpload1.SaveAs(filePath);//上传至服务器 string strConn = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties='text;HDR=Yes;FMT=Delimited';Data Source=" + fPath);
OleDbConnection conn = new OleDbConnection(strConn);
DataTable dt = new DataTable();
string sqlStr = "select * from " + fileName;
try
{
if (conn.State == ConnectionState.Closed)
conn.Open();
OleDbDataAdapter dr = new OleDbDataAdapter(sqlStr, conn);
DataSet ds = new DataSet();
dr.Fill(ds, "mytable");
dt = ds.Tables["mytable"];
}
catch
{ }
finally
{
conn.Close(); }
return dt;
这是读取CSV的代码
string fPath = Server.MapPath("\\") + "CardFile\\";//上传到服务器的文件夹路径
if (Directory.Exists(fPath) == false)
{
Directory.CreateDirectory(fPath);
}
string filePath = fPath + fileName;//绝对路径
FileUpload1.SaveAs(filePath);//上传至服务器 string strConn = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties='text;HDR=Yes;FMT=Delimited';Data Source=" + fPath);
OleDbConnection conn = new OleDbConnection(strConn);
DataTable dt = new DataTable();
string sqlStr = "select * from " + fileName;
try
{
if (conn.State == ConnectionState.Closed)
conn.Open();
OleDbDataAdapter dr = new OleDbDataAdapter(sqlStr, conn);
DataSet ds = new DataSet();
dr.Fill(ds, "mytable");
dt = ds.Tables["mytable"];
}
catch
{ }
finally
{
conn.Close(); }
return dt;
这是读取CSV的代码
var number = "1.203E16";
decimal decstr = decimal.Parse(number.ToString(), System.Globalization.NumberStyles.Any);
csv里的值是1203120200000001,程序读取出来的是1.2031205E+15 ,怎么把这个科学记数法的数值转换回去?long.parse这个好像不行
指定显示格式就可以了.