2016-12-14 6 views
0

다음 코드로 시트 이름을 사전 순으로 정렬하고 있습니다.Excel에서 시트 이름 가져 오기 ASP.Net

 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) 
     { 
     } 

원래 주문으로만 읽기만하면됩니다. 어떤 생각?

+0

무엇이 문제입니까? 어떤 오류가 있습니까? –

+0

코드 첫 번째 시트는 알파벳 순으로 실제 첫 번째 시트는 시트가 아닙니다. –

답변