问题:发现读取后的数据表中,当XLS中单位格的数据为全数字组成的时候 读取出来的数据就会是空的?例如:XLS里面的数据为
零件图号 零件名称
99100430018 转向横拉杆总成
99100430018A 转向横拉杆总成
99100430018 转向横拉杆总成
JY33STR-03050LQ 转向横拉杆总成
读取出来后:
零件图号 零件名称
转向横拉杆总成
99100430018A 转向横拉杆总成
转向横拉杆总成
JY33STR-03050LQ 转向横拉杆总成
代码如下:
SeNet.ExcelAccess excel = new ExcelAccess();
OpenFileDialog openFile = new OpenFileDialog(); OleDbConnection objConn = null;
OleDbDataAdapter objAdapter = null;
DataTable Subdt = null;
DataTable dt = null;
DataSet ds = null; //打开XLS文件
openFile.DefaultExt = "xls";
openFile.Filter = "电子表格文件 (*.xls)|*.xls";
DialogResult result = openFile.ShowDialog(); if (result != DialogResult.OK)
{
return;
} string strPathFiles = openFile.FileName;
excel.IsVisibledExcel = true;
//让XLS作为数据源
String connString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + strPathFiles + ";Extended Properties=Excel 8.0;";
objConn = new OleDbConnection(connString);
objConn.Open();//打开数据源
dt = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); if (dt == null)
{
return;
} //获取XLS所有工作簿名称
String[] excelSheets = new String[dt.Rows.Count];
int i = 0;
foreach (DataRow row in dt.Rows)
{
excelSheets[i] = row["TABLE_NAME"].ToString().Substring(0, row["TABLE_NAME"].ToString().Length - 1);
i++;
} //把每一个工作簿作为一个TABLE,保存到DATASET中
ds = new DataSet();
foreach (string tableName in excelSheets)
{
objAdapter = new OleDbDataAdapter("SELECT * FROM [" + tableName + "$] ", objConn);
Subdt = new DataTable();
objAdapter.Fill(Subdt);
Subdt.TableName = tableName;
ds.Tables.Add(Subdt);
}
objConn.Close();//关闭数据源
请高手帮忙想个法子~~~~~~~
零件图号 零件名称
99100430018 转向横拉杆总成
99100430018A 转向横拉杆总成
99100430018 转向横拉杆总成
JY33STR-03050LQ 转向横拉杆总成
读取出来后:
零件图号 零件名称
转向横拉杆总成
99100430018A 转向横拉杆总成
转向横拉杆总成
JY33STR-03050LQ 转向横拉杆总成
代码如下:
SeNet.ExcelAccess excel = new ExcelAccess();
OpenFileDialog openFile = new OpenFileDialog(); OleDbConnection objConn = null;
OleDbDataAdapter objAdapter = null;
DataTable Subdt = null;
DataTable dt = null;
DataSet ds = null; //打开XLS文件
openFile.DefaultExt = "xls";
openFile.Filter = "电子表格文件 (*.xls)|*.xls";
DialogResult result = openFile.ShowDialog(); if (result != DialogResult.OK)
{
return;
} string strPathFiles = openFile.FileName;
excel.IsVisibledExcel = true;
//让XLS作为数据源
String connString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + strPathFiles + ";Extended Properties=Excel 8.0;";
objConn = new OleDbConnection(connString);
objConn.Open();//打开数据源
dt = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); if (dt == null)
{
return;
} //获取XLS所有工作簿名称
String[] excelSheets = new String[dt.Rows.Count];
int i = 0;
foreach (DataRow row in dt.Rows)
{
excelSheets[i] = row["TABLE_NAME"].ToString().Substring(0, row["TABLE_NAME"].ToString().Length - 1);
i++;
} //把每一个工作簿作为一个TABLE,保存到DATASET中
ds = new DataSet();
foreach (string tableName in excelSheets)
{
objAdapter = new OleDbDataAdapter("SELECT * FROM [" + tableName + "$] ", objConn);
Subdt = new DataTable();
objAdapter.Fill(Subdt);
Subdt.TableName = tableName;
ds.Tables.Add(Subdt);
}
objConn.Close();//关闭数据源
请高手帮忙想个法子~~~~~~~
还有个问题 ,,他把"."读成了"#" - -!!
看看!
还有 "."读成了"#" 是因为他读到了TABLE的列名后改变的 也不知道怎么做