1
在C#中,如何從Excel文件的工作表中獲取列名?從Excel工作表中獲取列名
這裏是我到目前爲止的代碼:
ConnectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 12.0 Xml;HDR=YES;IMEX=1\";", "@"C:\file.xlsx");
objConn.Open();
OleDbCommand objCmdSelect = new OleDbCommand("SELECT * FROM ["xlWorksheet"$]", objConn);
OleDbDataAdapter objAdapter1 = new OleDbDataAdapter();
objAdapter1.SelectCommand = objCmdSelect;
DataSet objDataset1 = new DataSet();
objAdapter1.Fill(objDataset1);
objConn.Close();
[從c#中的excel文件中讀取列名稱]的可能的重複(http://stackoverflow.com/questions/3855101/read-column-names-from-excel-file-in-c) – codingbadger