private void btnExcelExport_Click(object sender, EventArgs e) { //불러오기 SFDialog.InitialDirectory = Application.StartupPath; SFDialog.FileName = "*.csv"; SFDialog.Filter = "xls files(*.xlsx)|*.xls|All files(*.*)|*.*"; if (SFDialog.ShowDialog() == DialogResult.OK) { ExcelExe excel = new ExcelExe(); string strFilePath = SFDialog.FileName; DataTable dt = dgData.DataSource as DataTable; ExcelExe.enExportType enType = ExcelExe.enExportType.EXCEL_COM; // excel api // excel.SaveExcel_COMAP(strFilePath, dt); // excel.SaveExcel_OLEDB(strFilePath, dt); string strRet = excel.ExcelExport(strFilePath, dt, enType); MessageBox.Show(strRet); //Export } }
/// <summary> /// Excel Export 진행 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnExport_Click(object sender, EventArgs e) { SFDialog.InitialDirectory = Application.StartupPath; SFDialog.FileName = "*.xls"; SFDialog.Filter = "xls files (*.xls)|*.elx|All files (*.*)|*.*"; if (SFDialog.ShowDialog() == DialogResult.OK) { ExcelExe excel = new ExcelExe(); string strFilePath = SFDialog.FileName; DataTable dt = dgData.DataSource as DataTable; ExcelExe.enExportType enType = ExcelExe.enExportType.EXCEL_COM; //ExcelExe.enExportType enType = ExcelExe.enExportType.OLEDB_EXCEL; //ExcelExe.enExportType enType = ExcelExe.enExportType.CSV_STREAM; string strRet = excel.ExcelExport(strFilePath, dt, enType); MessageBox.Show(strRet); } }