private void btGetList_Click() { try{ var scheduler = new SchedulerManager(_session); using (var lForm = new FrmGetList(_excelapp.Hwnd, scheduler.EnumFolders, scheduler.EnumReports)) { lForm.ReportsPath = _settings.GetWorksheetParam("ReportsPath", ""); lForm.AssociatedInstance = _settings.GetWorksheetParam("AssociatedInstance", ""); lForm.IncludePrompts = _settings.GetWorksheetParam("IncludePrompts", false); if (lForm.ShowDialog() == DialogResult.OK) { _settings.SetWorksheetParam("ReportsPath", lForm.ReportsPath); _settings.SetWorksheetParam("AssociatedInstance", lForm.AssociatedInstance); _settings.SetWorksheetParam("IncludePrompts", lForm.IncludePrompts); var runner = new FrmRunner(_session.Logger, scheduler.Cancel); Report[] reports = null; var exitcode = runner.Execute(() => scheduler.GetReports(lForm.ReportsPath, lForm.IncludePrompts, lForm.AssociatedInstance, out reports) ); if (exitcode == ExitCode.FAILED || exitcode == ExitCode.CANCELED) { return; } var worksheet = (Excel.Worksheet)_excelapp.ActiveSheet; SwitchExcelToIdle(_excelapp, false); worksheet.Cells.EntireColumn.Hidden = false; worksheet.Cells.EntireRow.Hidden = false; foreach (Excel.ListObject lo in worksheet.ListObjects) { lo.Delete(); } var data = _parser.ParseReportsToDataArray(reports); var title = _parser.ParseReportsToTitleArray(reports); var nbRow = data.GetLength(0); var nbCol = title.GetLength(1); var listobject = worksheet.ListObjects.Add(Excel.XlListObjectSourceType.xlSrcRange, worksheet.Cells.Resize[Math.Max(nbRow + 1, 2), nbCol], Type.Missing, Excel.XlYesNoGuess.xlYes); listobject.HeaderRowRange.Value = title; if (nbRow > 0) { listobject.DataBodyRange.NumberFormat = "@"; _parser.FormatListObject(listobject); listobject.DataBodyRange.Value = data; listobject.DataBodyRange.WrapText = false; _parser.AddPromptsNameAsComment(listobject, reports); } SwitchExcelToIdle(_excelapp, true); } } } catch (Exception ex) { new BusinessObjectsUtils.FrmException(_excelapp.Hwnd, ex).ShowDialog(); } }