private void txtLink_PreviewKeyDown(object sender, KeyEventArgs e) { ComboBox combobox = sender as ComboBox; // Open novel link in browser if (e.Key == Key.Enter && e.KeyboardDevice.Modifiers == ModifierKeys.Control) { if (!String.IsNullOrEmpty(combobox.Text) && combobox.Text.Length > 8 && combobox.Text.Substring(0, 8).Equals("https://", StringComparison.InvariantCultureIgnoreCase) ) { _shell.Open(combobox.Text); } } }
private void buttonOpenAndSaveFile_Click(object sender, EventArgs e) { if (openExceFileDialog.ShowDialog() == DialogResult.OK) { WorkBook workbook = WorkBook.Load(openExceFileDialog.FileName); DataTable dt = PrepareDataTable(); FillDataTableData(dt, 10); WorkSheet sheet = workbook.Sheets["任务单"]; if (sheet != null && sheet.Tables.Count > 0) { Table table = sheet.Tables[0]; table.FillData(dt.DefaultView); table.FillData(dt.DefaultView, (cell, cellParameters) => { cell.Value = cellParameters.PropertyValue; //cell.Style.Font.Color.SetColor(Color.Blue); cell.Style.Font.Color.SetColor(Color.White); cell.Style.Fill.SetBackgroundColor(Color.Blue, ExcelFillStyle.Solid); }); } string dir = Path.GetDirectoryName(Application.ExecutablePath); string path = Path.Combine(dir, "output.xlsx"); workbook.Save(path); Shell32.Shell shell = new Shell32.Shell(); shell.Open(path); } }