private void addButton_Click(object sender, EventArgs e) { ExcelWorkbookListItem listItem = workbookListBox.SelectedItem as ExcelWorkbookListItem; if (listItem is null) { return; } ExcelInterfaceUtility.OpenLinkAsSheet(listItem.Workbook, this.urlTextBox.Text); workbookListBox.Items.Clear(); this.Close(); }
private void MainForm_Load(object sender, EventArgs e) { string[] arguments = Environment.GetCommandLineArgs(); if (arguments.Length > 1) { string url = arguments[1]; if (!url.StartsWith(ProtocolName)) { MessageBox.Show(this, "Invalid arguments to program! Must be an excel protocol URL", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { urlTextBox.Text = "http" + url.Substring(ProtocolName.Length); } } IList <ExcelWorkbook> workbooks = ExcelInterfaceUtility.GetAllOpenWorkbooks(); workbookListBox.Items.Add(new ExcelWorkbookListItem(null, "New Excel Workbook")); foreach (ExcelWorkbook workbook in workbooks) { workbookListBox.Items.Add(new ExcelWorkbookListItem(workbook, null)); } }