public void TestWriteXslx() { MacroscopeJobMaster JobMaster = new MacroscopeJobMaster(MacroscopeConstants.RunTimeMode.LIVE); MacroscopeDataExtractorCssSelectors DataExtractorCssSelectors = new MacroscopeDataExtractorCssSelectors(1); MacroscopeDataExtractorRegexes DataExtractorRegexes = new MacroscopeDataExtractorRegexes(1); MacroscopeDataExtractorXpaths DataExtractorXpaths = new MacroscopeDataExtractorXpaths(1); MacroscopeExcelDataExtractorReport Report = new MacroscopeExcelDataExtractorReport(NewDataExtractorCssSelectors: DataExtractorCssSelectors, NewDataExtractorRegexes: DataExtractorRegexes, NewDataExtractorXpaths: DataExtractorXpaths); string Filename = string.Join(".", Path.GetTempFileName(), "xlsx"); Report.WriteXslx(JobMaster: JobMaster, OutputFilename: Filename); Assert.IsTrue(File.Exists(Filename)); File.Delete(Filename); }
/** -------------------------------------------------------------------- **/ private void CallbackSaveDataExtractorsExcelReport(object sender, EventArgs e) { 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-Data-Extractors.xlsx"; this.Enabled = false; if (Dialog.ShowDialog() == DialogResult.OK) { string Path = Dialog.FileName; MacroscopeExcelDataExtractorReport msExcelReport; msExcelReport = new MacroscopeExcelDataExtractorReport( NewDataExtractorCssSelectors: this.DataExtractorCssSelectors, NewDataExtractorRegexes: this.DataExtractorRegexes, NewDataExtractorXpaths: this.DataExtractorXpaths ); Cursor.Current = Cursors.WaitCursor; try { msExcelReport.WriteXslx(this.JobMaster, Path); } catch (MacroscopeSaveExcelFileException ex) { this.DialogueBoxError("Error saving Data Extractors Excel Report", ex.Message); } catch (Exception ex) { this.DialogueBoxError("Error saving Data Extractors Excel Report", ex.Message); } finally { Cursor.Current = Cursors.Default; } } if (Dialog != null) { Dialog.Dispose(); } this.Enabled = true; }