은 참조 :
string connString = @"Provider=Microsoft.ACE.OLEDB.12.0; Data Source=<YourExcelPath>;
Extended Properties=\"Excel 12.0;HDR=YES;\"";
OLEDB를 클래스 파일에서 정보를 조회하는 사용 후 :
string selectCmd = "SELECT * FROM <SheetName>";
using(OleDbConnection excelConn = new OleDbConnection(connString))
{
excelConn.Open();
OleDbCommand command = new OleDbCommand(selectCmd, excelConn);
OleDbDataAdapter da = new OleDbDataAdapter(command);
DataTable sheetInfo = new DataTable();
dataAdapter.Fill(sheetInfo);
//Do something with the data.
Bind your control with this datatable here
}
Reading Excel files from C#
가 적절한 연결 문자열을 필요 파일을 엑셀에 연결하려면
"YourExcelPath"를 Excel 파일의 경로로 바꿔야합니다.
[C#에서 Excel 파일 읽기] 가능한 복제본 (http://stackoverflow.com/questions/15828/reading-excel-files-from-c-sharp) –