OpenFileDialog dlg = new OpenFileDialog();
dlg.CheckFileExists = false;
dlg.DefaultExt = "xls";
dlg.Filter = "Excel 파일(*.xls,*.xlsx)|*.xls;*.xlsx";
dlg.Title = "거래처 Excel 자료 읽어오기";
dlg.ValidateNames = true;
DialogResult rt = dlg.ShowDialog();
dlg.DefaultExt = "xls";
dlg.Filter = "Excel 파일(*.xls,*.xlsx)|*.xls;*.xlsx";
dlg.Title = "거래처 Excel 자료 읽어오기";
dlg.ValidateNames = true;
DialogResult rt = dlg.ShowDialog();
//xls 구버전
string strCon = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dlg.FileName + ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1;ReadOnly=0;'";
string strCon = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dlg.FileName + ";Extended Properties='Excel 8.0;HDR=YES;IMEX=1;ReadOnly=0;'";
//xlsx 신버전 Mode=ReadWrite|Share Deny None;
string strCon = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + dlg.FileName + ";Extended Properties='Excel 12.0; HDR={1}; IMEX={2}';Persist Security Info=False";
string strCon = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + dlg.FileName + ";Extended Properties='Excel 12.0; HDR={1}; IMEX={2}';Persist Security Info=False";
댓글 없음 :
댓글 쓰기