【发布时间】:2016-12-19 19:43:17
【问题描述】:
我正在获取按下一个代码按字母顺序排序的工作表名称。
OleDbConnection connection = new OleDbConnection(string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}; Extended Properties=\"Excel 8.0;HDR=No;\"", filePath));
OleDbCommand command = new OleDbCommand();
DataTable tableOfData = null;
command.Connection = connection;
try
{
connection.Open();
tableOfData = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
string tablename = tableOfData.Rows[0]["TABLE_NAME"].ToString();
tableOfData = new DataTable();
command.CommandText = "Select * FROM [" + tablename + "]";
tableOfData.Load(command.ExecuteReader());
}
catch (Exception ex)
{
}
我只想按照原始顺序阅读它们。有什么想法吗?
【问题讨论】:
-
有什么问题?你遇到了什么错误?
-
代码返回第一张按字母顺序排列的不是实际的第一张。