private void BtnExportSimple_Click(object sender, EventArgs e) { ExportDataForm export = new ExportDataForm(ExportDataForm.DefaultList(), (DataTable)dgv.DataSource); export.ExportWithColumnName = chbxWithColName.Checked; export.ShowDialog(); }
/// <summary> /// Exports currently selected Excel data to a new MySQL table or appends it to an existing MySQL table. /// </summary> /// <param name="toTableObject">Table to append the data to, if null exports to a new table.</param> /// <returns><c>true</c> if the export/append action was executed, <c>false</c> otherwise.</returns> public bool AppendDataToTable(DbTable toTableObject) { DialogResult dr; if (!(Globals.ThisAddIn.Application.Selection is ExcelInterop.Range exportRange)) { return(false); } if (exportRange.Areas.Count > 1) { InfoDialog.ShowDialog(InfoDialogProperties.GetWarningDialogProperties(Resources.MultipleAreasNotSupportedWarningTitle, Resources.MultipleAreasNotSupportedWarningDetail)); return(false); } Cursor = Cursors.WaitCursor; if (toTableObject != null) { using (var appendDataForm = new AppendDataForm(toTableObject, exportRange, ActiveWorksheet.Name)) { dr = appendDataForm.ShowDialog(); } } else { using (var exportForm = new ExportDataForm(WbConnection, exportRange, ActiveWorksheet.Name)) { dr = exportForm.ShowDialog(); } } Cursor = Cursors.Default; return(dr == DialogResult.OK); }
private void btnExportCustom_Click(object sender, EventArgs e) { List <BaseExportComponentFrom> components = new List <BaseExportComponentFrom>(); components.AddRange(ExportDataForm.DefaultList()); components.Add(new Export.XlsExportFrom()); ExportDataForm export = new ExportDataForm(components.AsReadOnly(), (DataTable)dgv.DataSource); export.ExportWithColumnName = chbxWithColName.Checked; export.ShowDialog(); }