// 2.加入鞋圖 private void toExcel_Click(object sender, EventArgs e) { // 2秒內避免重複按出錯 DateTime localDateTime = DateTime.Now; double now = localDateTime.ToUniversalTime().Subtract( new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds; if (now - buttonClickMilliseconds < 2000) { return; } else { buttonClickMilliseconds = now; } if (bwGenExcelArgs.sourceFile == null || (!(File.Exists(bwGenExcelArgs.sourceFile)))) { Fun.showMessageBox("Please choose a excel file", "Caution"); return; } bwGenExcelArgs.imageHeight = Fun.imageHeightRange(Math.Abs(trackBarImageHeight.Value)); // 取圖片副檔名順序存入LIST if (rbExt1.Checked) { bwGenExcelArgs.imagePriorityList = Fun.getExtPriorityList(1); } else { bwGenExcelArgs.imagePriorityList = Fun.getExtPriorityList(2); } // 取Excel圖片路徑的column bwGenExcelArgs.excelImagePathColumnIdx = Int32.Parse( (cbPathColumn.SelectedItem as ComboboxItem).Value.ToString() ); // Excel新增圖片的column bwGenExcelArgs.excelAddImageColumnIdx = Int32.Parse( (cbImageColumn.SelectedItem as ComboboxItem).Value.ToString() ); // Excel新增圖片的column是否要insert一欄 bwGenExcelArgs.excelColumnInsert = chKBoxInsColumn.Checked; // 線程產生Excel BwGenExcel bw_DoWork = new BwGenExcel(bwGenExcelArgs); bw = new BackgroundWorker(); bw.WorkerReportsProgress = true; bw.WorkerSupportsCancellation = true; bw.DoWork += new DoWorkEventHandler(bw_DoWork.DoWork); bw.ProgressChanged += new ProgressChangedEventHandler(bw_ProgressChanged); bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted); // disable button this.SetButtonStatus(false); bw.RunWorkerAsync(); }