private int Execute(ActivityContext context, IWorkbookAdapter adapter) { var sheetName = SheetName.Get(context); var range = CellRange.Get(context); return(adapter.RemoveHyperlink(sheetName, range)); }
public static IWorkbookAdapter Create(string path) { IWorkbookAdapter adapter = null; using (var f = File.OpenRead(path)) { if (f.Length == 0) { throw new InvalidOperationException("The file is empty (zero bytes long)"); } var extension = Path.GetExtension(path); switch (extension.ToLowerInvariant()) { case ".xlsm": // macro enabled workbook case ".xltm": // macro enabled template case ".xlsx": // workbook case ".xltx": // template adapter = new OpenXmlWorkbookAdapter(); break; default: adapter = new OLE2WorkbookAdapter(); break; } } if (adapter == null) { throw new InvalidOperationException("The file stream need be a OLE2 or OOXML stream"); } adapter.Open(path); return(adapter); }
protected override int Execute(CodeActivityContext context) { if (UseScope) { return(ExecuteWithScope(context)); } var path = WorkbookPath.Get(context); if (!File.Exists(path)) { throw new FileNotFoundException(path); } IWorkbookAdapter workbook = null; try { workbook = WorkbookAdapterFactory.Create(path); return(Execute(context, workbook)); } catch (Exception) { return(-1); } finally { workbook?.Dispose(); } }
private string[] Execute(ActivityContext context, IWorkbookAdapter adapter) { var sheetName = SheetName.Get(context); var range = CellRange.Get(context); return(adapter.GetHyperlinks(sheetName, range).ToArray()); }
protected override string[] Execute(CodeActivityContext context) { if (UseScope) { return(ExecuteWithScope(context)); } var path = WorkbookPath.Get(context); if (!File.Exists(path)) { throw new FileNotFoundException(path); } IWorkbookAdapter workbook = null; try { workbook = WorkbookAdapterFactory.Create(path); return(Execute(context, workbook)); } catch (Exception e) { System.Diagnostics.Trace.WriteLine(e.Message); throw; } finally { workbook?.Dispose(); } }
private bool Execute(ActivityContext context, IWorkbookAdapter adapter) { var sheetName = SheetName.Get(context); var cellAddress = Cell.Get(context); var link = Link.Get(context); var label = Label.Get(context); var tooltip = Tooltip.Get(context); adapter.AddHyperlink(sheetName, cellAddress, label, link, tooltip); return(true); }
protected override string[] Execute(CodeActivityContext context) { if (UseScope) { return(ExecuteWithScope(context)); } IWorkbookAdapter workbook = null; try { var filePath = WorkbookPath.Get(context); workbook = WorkbookAdapterFactory.Create(filePath); return(workbook.GetSheetNames()); } finally { workbook?.Dispose(); } }
private string Execute(ActivityContext context, IWorkbookAdapter adapter) { var index = SheetIndex.Get(context); return(adapter.GetSheetName(index)); }