在C#中使用oledb连接字符串如何将科学符号转换为文本字符串?
我有一组数据,使用OLEDB连接字符串作为Excel文件下载,如下所示: 4552 3.00E+03 3.00E+22 3F45 3.00E+99 DD56677 37 Excel自动认为3E03、3E22和3E99是数字,并使它们看起来像上面的一样 如何将其作为字符串获取 我的代码是在C#中使用oledb连接字符串如何将科学符号转换为文本字符串?,c#,excel,oledbconnection,C#,Excel,Oledbconnection,我有一组数据,使用OLEDB连接字符串作为Excel文件下载,如下所示: 4552 3.00E+03 3.00E+22 3F45 3.00E+99 DD56677 37 Excel自动认为3E03、3E22和3E99是数字,并使它们看起来像上面的一样 如何将其作为字符串获取 我的代码是 DataTable dataTable = new DataTable(); strExcelConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
DataTable dataTable = new DataTable();
strExcelConn = "Provider=Microsoft.Jet.OLEDB.4.0;"
+ "Data Source=" + strFilePath + ";"
+ "Extended Properties='Excel 8.0;HDR=" + header + ";IMEX=1;TypeGuessRows=0;ImportMixedTypes=Text'";
OleDbConnection connection = new OleDbConnection(strExcelConn);
using (OleDbCommand command = new OleDbCommand())
using (OleDbDataAdapter adapter = new OleDbDataAdapter(command))
{
command.Connection = connection;
//Check if the Sheet Exists
connection.Open();
DataTable dtExcelSchema;
//Get the Schema of the WorkBook
dtExcelSchema = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
connection.Close();
connection.Open();
DataSet ds = new DataSet();
string SheetName = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString();
command.CommandText = "SELECT * From [" + SheetName + "]";
adapter.SelectCommand = command;
adapter.Fill(dataTable);
connection.Close();
}
请任何人帮我把这根柱子做成一个字符串看看这道题为的题
他们使用
decimal.Parse(someMoneyVar,NumberStyles.Any)
方法进行转换。在查询中按名称选择Excel列,并使用CStr()将所需列转换为字符串。