public static ExcelWrapper CreateInstance() { int assignedId = GetNextId(); ExcelWrapper wrapper = new ExcelWrapper(assignedId); launchedExcels.Add(wrapper); CurrentExcel = wrapper; return(wrapper); }
public static void SwitchExcel(int id) { ExcelWrapper instanceToSwitchTo = launchedExcels.Where(x => x.Id == id).FirstOrDefault(); if (instanceToSwitchTo == null) { throw new ArgumentException($"No excel instance found with id: {id}"); } CurrentExcel = instanceToSwitchTo; }
public void Execute(Arguments arguments) { try { ExcelWrapper excelWrapper = ExcelManager.CreateInstance(); excelWrapper.Open(arguments.Path?.Value, arguments.Sheet?.Value, !arguments.InBackground.Value); Scripter.Variables.SetVariableValue(arguments.Result.Value, new Language.IntegerStructure(excelWrapper.Id)); } catch (Exception ex) { throw new ApplicationException($"Problem occured while opening excel instance. Path: '{arguments.Path.Value}', Sheet: '{arguments.Sheet?.Value}', InBackground: '{arguments.InBackground.Value}'", ex); } }
public void Execute(Arguments arguments) { try { ExcelWrapper excelWrapper = ExcelManager.CreateInstance(); excelWrapper.Open(arguments.Path?.Value, arguments.Sheet?.Value, !arguments.InBackground.Value); Scripter.Variables.SetVariableValue(arguments.Result.Value, new IntegerStructure(excelWrapper.Id)); } catch (Exception ex) { if (ex.GetType() == typeof(COMException) && ex.Message.Contains("80040154")) { throw new Exception("Could not find Microsoft Office on computer. Please make sure it is installed and try again."); } throw new ApplicationException($"Problem occured while opening excel instance. Path: '{arguments.Path?.Value}', Sheet: '{arguments.Sheet?.Value}', InBackground: '{arguments.InBackground.Value}'", ex); } }