예제 #1
0
        /**************************************************************************/

        private void CallbackExportListViewToExcelReport(object sender, EventArgs e)
        {
            KeyValuePair <string, ListView> SelectedListView;

            SaveFileDialog Dialog = new SaveFileDialog();

            Dialog.Filter           = "Excel files (*.xlsx)|*.xlsx|All files (*.*)|*.*";
            Dialog.FilterIndex      = 2;
            Dialog.RestoreDirectory = true;
            Dialog.DefaultExt       = "xlsx";
            Dialog.AddExtension     = true;
            Dialog.FileName         = "Macroscope-Report.xlsx";

            this.Enabled = false;

            SelectedListView = this.GetTabPageListView();

            if (SelectedListView.Value != null)
            {
                if (Dialog.ShowDialog() == DialogResult.OK)
                {
                    string Path = Dialog.FileName;
                    MacroscopeExcelExportListViewReport msExcelReport;

                    msExcelReport = new MacroscopeExcelExportListViewReport(
                        SelectedWorksheetName: SelectedListView.Key,
                        SelectedListView: SelectedListView.Value
                        );

                    try
                    {
                        msExcelReport.WriteXslx(this.JobMaster, Path);
                    }
                    catch (MacroscopeSaveExcelFileException ex)
                    {
                        this.DialogueBoxError("Error saving Excel Report", ex.Message);
                    }
                    catch (Exception ex)
                    {
                        this.DialogueBoxError("Error saving Excel Report", ex.Message);
                    }
                }
            }
            else
            {
                this.DialogueBoxError("Error saving Excel Report", "Cannot export this view type");
            }

            Dialog.Dispose();

            this.Enabled = true;
        }
예제 #2
0
        /**************************************************************************/

        private void CallbackExportListViewToExcelReport(object sender, EventArgs e)
        {
            KeyValuePair <string, ListView> SelectedListView = this.GetTabPageListView();

            SaveFileDialog Dialog = new SaveFileDialog();

            Dialog.Filter           = "Excel files (*.xlsx)|*.xlsx|All files (*.*)|*.*";
            Dialog.FilterIndex      = 2;
            Dialog.RestoreDirectory = true;
            Dialog.DefaultExt       = "xlsx";
            Dialog.AddExtension     = true;
            Dialog.FileName         = "Macroscope-Report.xlsx";

            if (Dialog.ShowDialog() == DialogResult.OK)
            {
                string Path = Dialog.FileName;
                MacroscopeExcelExportListViewReport msExcelReport;

                msExcelReport = new MacroscopeExcelExportListViewReport(
                    SelectedWorksheetName: SelectedListView.Key,
                    SelectedListView: SelectedListView.Value
                    );

                try
                {
                    if (Macroscope.MemoryGuard(RequiredMegabytes: ExcelReportMegabytesRamRequired))
                    {
                        msExcelReport.WriteXslx(this.JobMaster, Path);
                    }
                }
                catch (MacroscopeInsufficientMemoryException ex)
                {
                    this.DialogueBoxError("Error saving Excel Report", ex.Message);
                }
                catch (MacroscopeSaveExcelFileException ex)
                {
                    this.DialogueBoxError("Error saving Excel Report", ex.Message);
                }
                catch (Exception ex)
                {
                    this.DialogueBoxError("Error saving Excel Report", ex.Message);
                }
            }

            Dialog.Dispose();
        }